New submission from Frank Millman:
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
Peter Otten added the comment:
Assuming that the current behaviour is by accident here's a patch that adds the
bytes type to the _copy_dispatch registry.
--
keywords: +patch
nosy: +peter.otten
Added file: http://bugs.python.org/file34244/copy_bytes.patch
STINNER Victor added the comment:
bytes is immutable, I don't why we would duplicate it.
--
nosy: +haypo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20791
___
Changes by Yury Selivanov yselivanov...@gmail.com:
--
nosy: +yselivanov
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20791
___
___
R. David Murray added the comment:
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.
--
nosy: +r.david.murray
versions: +Python 3.4, Python 3.5
___
Python
Antoine Pitrou added the comment:
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/
--
nosy: +pitrou
stage: - patch review
versions: -Python 3.3
___
Peter Otten added the comment:
I did sign today (and received the confirmation email).
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20791
___
Roundup Robot added the comment:
New changeset c2523bca50d7 by Antoine Pitrou in branch 'default':
Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes
object. Initial patch by Peter Otten.
http://hg.python.org/cpython/rev/c2523bca50d7
--
nosy: +python-dev
Antoine Pitrou added the comment:
Ok, thank you! This will be in 3.4.1 and 3.5.
--
resolution: - fixed
stage: patch review - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20791
STINNER Victor added the comment:
Why not fixing this bug in Python 3.3 too?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20791
___
___
Antoine Pitrou added the comment:
Is Python 3.3 still allowing bug fixes?
If yes, this is a good idea. Do you want to backport it?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20791
___
R. David Murray added the comment:
3.3 will get fixes until its final release, which will be some time after the
release of 3.4.0.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20791
___
Roundup Robot added the comment:
New changeset b3fb7828b6fc by Antoine Pitrou in branch '3.3':
Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes
object. Initial patch by Peter Otten.
http://hg.python.org/cpython/rev/b3fb7828b6fc
--
13 matches
Mail list logo