[issue17742] Add _PyBytesWriter API

Serhiy Storchaka report at bugs.python.org
Fri Apr 19 22:18:53 CEST 2013


Serhiy Storchaka added the comment:

_PyBytesWriter and _PyUnicodeWriter have differen use cases. While _PyUnicodeWriter used primary in formatter where resulting size is rarely known and reallocation in decoders usually caused by widening result, _PyBytesWriter is used only in decoders where we usually can estimate a result size or it's upper bound. Resizing happened only in exceptional cases, when error handler called.

The patch contains a special case for writing only one bytes object. This is very unlikely case. It happened only when an encoded string contains only one illegal character. I think this case is not worth a complication and
obfuscation of the code. I think we should drop readonly attribute and a piece of the code (which looks buggy for me anyway).

----------

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


More information about the Python-bugs-list mailing list