Uh oh!
There was an error while loading. Please reload this page.
Use bytearray for buffer in _UnixWritePipeTransport - #385
Conversation
benchmark: draintest.py master: socketpair:writev (#339) methane:unix-events-bytearray-buffer |
Another benchmark draintest2.py #339 : this pull request: |
More combination of chunksize. draintest3.py #339 : this pull request: So, when chunk is small (~10KB), When chunk is large (100KB), |
methane
commented
Jul 22, 2016
@socketpair Could you confirm draintest3.py bench? |
| self._loop.add_writer(self._fileno, self._write_ready) | ||
| self._buffer.append(data) | ||
| self._buffer += data |
There was a problem hiding this comment.
This is bad knowhow: operator is faster than method, thanks to slot.
In [2]: defpluseq():
...: buf=bytearray()
...: for_inrange(1000):
...: buf+=b'foo'
...: In [3]: defextend():
...: buf=bytearray()
...: for_inrange(1000):
...: buf.extend(b'foo')
...: In [4]: %timeitpluseq()
10000loops, bestof3: 80.2µsperloopIn [5]: %timeitextend()
10000loops, bestof3: 135µsperloopThere was a problem hiding this comment.
And more important: bytearray.extend() accepts sequence of integers [0, 255).
In [6]: buf = bytearray()
In [7]: buf += [1,2,3]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-d99af3f0cf4a> in <module>()
----> 1 buf += [1,2,3]
TypeError: can't concat list to bytearray
In [8]: buf.extend([1,2,3])
In [9]: buf
Out[9]: bytearray(b'\x01\x02\x03')
There was a problem hiding this comment.
In [6]: buf = bytearray()
In [7]: buf += [1,2,3]
This should not be allowed. Supporting this would make life for other loop implementations harder with no obvious benefits.
There was a problem hiding this comment.
@1st1 Yes, it raises TypeError, as you can see above.
socketpair
commented
Jul 22, 2016
what does that mean ? |
methane
commented
Jul 22, 2016
@socketpair I meant could you confirm draintest3.py measures right thing, and benchmark in you environment. |
1st1
commented
Sep 15, 2016
Committed in 6f8f833. Thank you! |
fixes#384
This pull request is a control experiment of #339.