Feature
bytes object is immutable, so constructing a new bytes object from another bytes object doesn't need copying.
However, PyBytes and PyByteArray share PyBytesInner implementation, causing an unnecessary copying of immutable data.
CPython:
>>> b = b'foo'
>>> bytes(b) is b
True
RustPython:
>>> b = b'foo'
>>> bytes(b) is b
False
Python Documentation
https://docs.python.org/3/library/stdtypes.html#bytes-objects
Feature
bytesobject is immutable, so constructing a newbytesobject from anotherbytesobject doesn't need copying.However,
PyBytesandPyByteArraysharePyBytesInnerimplementation, causing an unnecessary copying of immutable data.CPython:
RustPython:
Python Documentation
https://docs.python.org/3/library/stdtypes.html#bytes-objects