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.

Author serhiy.storchaka
Recipients christian.heimes, petr.viktorin, pitrou, serhiy.storchaka, skrah, vstinner
Date 2021-10-19.08:23:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634631796.64.0.841330396441.issue45459@roundup.psfhosted.org>
In-reply-to
Content
Py_buffer is often used for handling arguments if the function supports bytes, bytearray and other bytes-like objects. For example bytes.partition(). Any additional memory allocation would add significant overhead here. bytes.join() creates Py_buffer for every item, it would be a deoptimization if it would need to allocate them all separately.

We should allow to allocate Py_buffer on stack. Currently it has too complex structure and we cannot guarantee its stability (although there were no changes for years). I propose to split Py_buffer on transparent and opaque parts and standardize the transparent structure. It should include: obj, buf, len, possible flags (to distinguish read-only from writeable) and a pointer to opaque data. For bytes, bytearray, BytesIO, mmap and most other classes the pointer to opaque data is NULL. For array and memoryview objects the opaque data could be embedded into the object.
History
Date User Action Args
2021-10-19 08:23:16serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, vstinner, christian.heimes, petr.viktorin, skrah
2021-10-19 08:23:16serhiy.storchakasetmessageid: <1634631796.64.0.841330396441.issue45459@roundup.psfhosted.org>
2021-10-19 08:23:16serhiy.storchakalinkissue45459 messages
2021-10-19 08:23:16serhiy.storchakacreate