[issue20791] copy.copy(bytes) is slow

Frank Millman report at bugs.python.org
Thu Feb 27 09:58:03 CET 2014


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
>>> 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

----------
components: Library (Lib)
messages: 212340
nosy: frankmillman
priority: normal
severity: normal
status: open
title: copy.copy(bytes) is slow
type: performance
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20791>
_______________________________________


More information about the Python-bugs-list mailing list