Skip to content

bytes(bytes) is inefficient #2125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
edwardycl opened this issue Aug 17, 2020 · 1 comment
Closed

bytes(bytes) is inefficient #2125

edwardycl opened this issue Aug 17, 2020 · 1 comment
Labels
C-compat A discrepancy between RustPython and CPython

Comments

@edwardycl
Copy link
Contributor

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

@awoimbee
Copy link
Contributor

Fixed by #2284
@qingshi163 you should use github keywords (Fixes #<issue number>) ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-compat A discrepancy between RustPython and CPython
Projects
None yet
Development

No branches or pull requests

4 participants