[issue17742] Add _PyBytesWriter API

STINNER Victor report at bugs.python.org
Sun Apr 21 04:03:28 CEST 2013


STINNER Victor added the comment:

I'm not completly satisfied of bytes_writer-2.patch. Most encoders work directly on a pointer (char*). If I want to keep the code using pointers (because it is efficient), I have to resynchronize the writer and the pointer before and after calling writer methods.

Here is a new patch implementing a different approach, closer to the current code. The patch version 3 has no "pos" attribute: the "position" is now a pointer (str). So encoders can just use this pointer instead of their own pointer.

I expect that replacing "*p++ = c;" with "*writer.str++ = c;" would not add an important overhead, especially because writer is a local variable, and str is the first attribute of the structure. I hope that the machine code will be exactly the same.

----------
Added file: http://bugs.python.org/file29961/bytes_writer-3.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17742>
_______________________________________


More information about the Python-bugs-list mailing list