[Python-Dev] io.BytesIO slower than monkey-patching io.RawIOBase (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Tue Jul 17 10:35:02 CEST 2012
- Previous message: [Python-Dev] io.BytesIO slower than monkey-patching io.RawIOBase
- Next message: [Python-Dev] io.BytesIO slower than monkey-patching io.RawIOBase
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 17 Jul 2012 06:34:14 +0300 Eli Bendersky <eliben at gmail.com> wrote:
Is there any reason for this to be so? What does BytesIO give us that the second approach does not (I tried adding more methods to the patched RawIOBase to make it more functional, like seekable() and tell(), and it doesn't affect performance)?
Well, try implementing non-trivial methods such as readline() or seek(), and writing in the middle rather than at the end.
As Nick said, we could implement the same optimization as in StringIO, i.e. only materialize the buffer when necessary.
Regards
Antoine.
-- Software development and contracting: http://pro.pitrou.net
- Previous message: [Python-Dev] io.BytesIO slower than monkey-patching io.RawIOBase
- Next message: [Python-Dev] io.BytesIO slower than monkey-patching io.RawIOBase
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]