Author serhiy.storchaka
Recipients jonathanunderwood, r.david.murray, serhiy.storchaka
Date 2017-12-27.17:14:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Much C code implies that bytes are null terminated. For example bytes-to-number converters and most functions that accept bytes as file path. Changing just the compare logic will not help.

The documented way of changing the size of the bytes object is _PyBytes_Resize(). But since this is a private function the only way of resizing the bytes object using public functions is creating a new object with PyBytes_FromStringAndSize(). If the new size is 0, it will return a singleton, thus this is a fast and memory efficient way.

Using the Py_SIZE() macro with the bytes object is not even documented. We should either document this way with its caveats (for example misusing it can lead to inefficient use of memory), or admit that this is working with internal representation which we shouldn't encourage.
Date User Action Args
2017-12-27 17:14:57serhiy.storchakasetrecipients: + serhiy.storchaka, r.david.murray, jonathanunderwood
2017-12-27 17:14:57serhiy.storchakasetmessageid: <>
2017-12-27 17:14:57serhiy.storchakalinkissue32431 messages
2017-12-27 17:14:57serhiy.storchakacreate