This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Use _PyBytesWriter in the binascii module
Type: Stage:
Components: Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, vstinner
Priority: normal Keywords: patch

Created on 2015-10-12 11:40 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
binascii_writer.patch vstinner, 2015-10-12 11:40 review
Messages (4)
msg252852 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-10-12 11:40
Attached patch modifies the binascii module to use the new _PyBytesWriter API.

IMHO the patch makes the code more readable. The code may be faster because it avoids a call to _PyBytes_Resize() in some cases.

The change on binascii_rledecode_hqx_impl() should be carefully reviewed, the code is a little bit more complex. It uses a counter to decide when to enlarge the buffer. It calls _PyBytesWriter_Prepare() to enlarge the buffer which uses overallocation. It disables overallocation if we are going to write the last byte.
msg252853 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-10-12 11:40
I implemented the "use empty string singleton" optimization in _PyBytesWriter_Finish(): see changeset f33433d9c163.
msg252920 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-10-13 08:52
New changeset d6fcda2b9b5e by Victor Stinner in branch 'default':
Issue #25384: Use _PyBytesWriter API in binascii
https://hg.python.org/cpython/rev/d6fcda2b9b5e
msg252993 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-10-14 13:31
New changeset 32b17c3b3cf3 by Victor Stinner in branch 'default':
Issue #25384: Fix binascii.rledecode_hqx()
https://hg.python.org/cpython/rev/32b17c3b3cf3
History
Date User Action Args
2022-04-11 14:58:22adminsetgithub: 69571
2015-10-14 13:31:50python-devsetmessages: + msg252993
2015-10-13 08:53:05vstinnersetstatus: open -> closed
resolution: fixed
2015-10-13 08:52:53python-devsetnosy: + python-dev
messages: + msg252920
2015-10-12 11:40:59vstinnersetmessages: + msg252853
2015-10-12 11:40:15vstinnercreate