[Python-Dev] io.BytesIO slower than monkey-patching io.RawIOBase (original) (raw)
John O'Connor jxo6948 at rit.edu
Tue Jul 17 06:57:04 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 ]
The second approach is consistently 10-20% faster than the first one (depending on input) for trunk Python 3.3
I think the difference is that StringIO spends extra time reallocating memory during the write loop as it grows, whereas bytes.join computes the allocation size first since it already knows the final length.
- 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 ]