Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork185
Use bytearray for buffer in _UnixWritePipeTransport#385
Uh oh!
There was an error while loading.Please reload this page.
Conversation
methane commentedJul 22, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
benchmark:draintest.py master: socketpair:writev (#339) methane:unix-events-bytearray-buffer |
methane commentedJul 22, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Another benchmarkdraintest2.py #339 : this pull request: |
methane commentedJul 22, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
More combination of chunksize.draintest3.py #339 : this pull request: So, when chunk is small (~10KB), When chunk is large (100KB), |
methane commentedJul 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
use.extend() seems it is faster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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µsperloop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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 bytearrayIn [8]: buf.extend([1,2,3])In [9]: bufOut[9]: bytearray(b'\x01\x02\x03')There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@1st1 Yes, it raises TypeError, as you can see above.
socketpair commentedJul 22, 2016
what does that mean ? |
methane commentedJul 22, 2016
@socketpair I meant could you confirm draintest3.py measures right thing, and benchmark in you environment. |
1st1 commentedSep 15, 2016
Committed in6f8f833. Thank you! |
Uh oh!
There was an error while loading.Please reload this page.
fixes#384
This pull request is a control experiment of#339.