[Python-Dev] [Python-checkins] cpython: asyncio: Change write buffer use to avoid O(N**2). Make write()/sendto() accept (original) (raw)
Victor Stinner victor.stinner at gmail.com
Wed Nov 27 23:57:25 CET 2013
- Previous message: [Python-Dev] potential argparse problem: bad mix of parse_known_args and prefix matching
- Next message: [Python-Dev] test_uuid.py on HP NonStop Python-2.7.5 fails (test case: testIssue8621)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2013/11/27 guido.van.rossum <python-checkins at python.org>:
http://hg.python.org/cpython/rev/80e0040d910c changeset: 87617:80e0040d910c user: Guido van Rossum <guido at python.org> date: Wed Nov 27 14:12:48 2013 -0800 summary: asyncio: Change write buffer use to avoid O(N**2). Make write()/sendto() accept bytearray/memoryview too. Change some asserts with proper exceptions.
Was this change discussed somewhere? Antoine told me on IRC that it was discussed on the tulip mailing list. I would be nice to mention it in the commit message (for the next change ;-).
diff --git a/Lib/asyncio/selectorevents.py b/Lib/asyncio/selectorevents.py --- a/Lib/asyncio/selectorevents.py +++ b/Lib/asyncio/selectorevents.py @@ -340,6 +340,8 @@
maxsize = 256 * 1024 # Buffer size passed to recv(). + bufferfactory = bytearray # Constructs initial value for self.buffer. +
Because the buffer type is now configurable, it would be nice to explain in a short comment why bytearray fits better this use case.
(I like the bytearray object, so I like your whole changeset!)
@@ -762,6 +776,8 @@
class SelectorDatagramTransport(SelectorTransport): + bufferfactory = collections.deque + def init(self, loop, sock, protocol, address=None, extra=None): super().init(loop, sock, protocol, extra) self.address = address
Why collections.deque is preferred here? Could you also please add a comment?
Victor
- Previous message: [Python-Dev] potential argparse problem: bad mix of parse_known_args and prefix matching
- Next message: [Python-Dev] test_uuid.py on HP NonStop Python-2.7.5 fails (test case: testIssue8621)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]