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
copy.copy(bytes) is slow #64990
Comments
Using copy.copy on a byte string returns a new copy instead of the original immutable object. Using copy.deepcopy returns the original, as expected. Testing with timeit, copy.copy is much slower than copy.deepcopy. >>> import copy
>>>
>>> a = 'a'*1000 # string
>>> copy.copy(a) is a
True
>>> copy.deepcopy(a) is a
True
>>>
>>> b = b'b'*1000 # bytes
>>> copy.copy(b) is b
False
>>> copy.deepcopy(b) is b
True |
Assuming that the current behaviour is by accident here's a patch that adds the bytes type to the _copy_dispatch registry. |
bytes is immutable, I don't why we would duplicate it. |
We probably just forgot to add it when the bytes type was added, and there was of course no test that would fail since it was a new type. |
Thanks for the patch, Peter. Could you sign a contributor's agreement? You can do so online at http://www.python.org/psf/contrib/contrib-form/ |
I did sign today (and received the confirmation email). |
New changeset c2523bca50d7 by Antoine Pitrou in branch 'default': |
Ok, thank you! This will be in 3.4.1 and 3.5. |
Why not fixing this bug in Python 3.3 too? |
Is Python 3.3 still allowing bug fixes? |
3.3 will get fixes until its final release, which will be some time after the release of 3.4.0. |
New changeset b3fb7828b6fc by Antoine Pitrou in branch '3.3': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: