gh-156939: Document that PyBytesObject ends with a NUL byte - #157236
Conversation
Documentation build overview
57 files changed ·
|
|
The trailing NUL byte property is already documented in:
|
For consistency with the page.
|
Seems worth mentioning to me! |
|
I'd rather keep this in the function docs. Or if it needs to be here, then as a CPython implementation detail. (In another implementation, |
Ah ok, I see you point. It sounds inefficient to me to duplicate the whole string in PyBytes_AsString() to add an extra null byte. It would be more efficient to always allocate that byte. But I take your point and I modified to note to document it as a CPython implementation detail. |
encukou
left a comment
There was a problem hiding this comment.
It sounds inefficient to me to duplicate the whole string in
PyBytes_AsString()to add an extra null byte.
In CPython, yes. I'm thinking about Jython-ish implementations where bytes could often reuse storage of a “native” object.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
Oh, in fact bytearray also has this trailing null byte. I update my PR to add a similar implementation detail note to bytearray. |
Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
I updated the branch to retrieve a fix for the Docs CI. |
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
GH-157550 is a backport of this pull request to the 3.15 branch. |
|
GH-157551 is a backport of this pull request to the 3.14 branch. |
|
GH-157552 is a backport of this pull request to the 3.13 branch. |
…H-157236) (#157551) gh-156939: Document that PyBytesObject ends with a NUL byte (GH-157236) Document as an implementation detail that PyBytesObject and ByteArrayObject end with a NUL byte. (cherry picked from commit 2fcb0e2) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
…H-157236) (#157552) gh-156939: Document that PyBytesObject ends with a NUL byte (GH-157236) Document as an implementation detail that PyBytesObject and ByteArrayObject end with a NUL byte. (cherry picked from commit 2fcb0e2) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
Thanks for your help on that doc change @encukou. @ngoldbaum spotted that RustPython omits this trailing null bytes in its C API! RustPython/RustPython#8685 |
Uh oh!
There was an error while loading. Please reload this page.