Issue20791
Created on 2014-02-27 08:58 by frankmillman, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| copy_bytes.patch | peter.otten, 2014-02-27 09:40 | review | ||
| Messages (12) | |||
|---|---|---|---|
| msg212340 - (view) | Author: Frank Millman (frankmillman) | Date: 2014-02-27 08:58 | |
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 |
|||
| msg212344 - (view) | Author: Peter Otten (peter.otten) * | Date: 2014-02-27 09:40 | |
Assuming that the current behaviour is by accident here's a patch that adds the bytes type to the _copy_dispatch registry. |
|||
| msg212345 - (view) | Author: STINNER Victor (vstinner) * | Date: 2014-02-27 09:46 | |
bytes is immutable, I don't why we would duplicate it. |
|||
| msg212354 - (view) | Author: R. David Murray (r.david.murray) * | Date: 2014-02-27 14:02 | |
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. |
|||
| msg212377 - (view) | Author: Antoine Pitrou (pitrou) * | Date: 2014-02-27 19:27 | |
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/ |
|||
| msg212383 - (view) | Author: Peter Otten (peter.otten) * | Date: 2014-02-27 20:39 | |
I did sign today (and received the confirmation email). |
|||
| msg212388 - (view) | Author: Roundup Robot (python-dev) | Date: 2014-02-27 21:16 | |
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 |
|||
| msg212389 - (view) | Author: Antoine Pitrou (pitrou) * | Date: 2014-02-27 21:16 | |
Ok, thank you! This will be in 3.4.1 and 3.5. |
|||
| msg212392 - (view) | Author: STINNER Victor (vstinner) * | Date: 2014-02-27 22:53 | |
Why not fixing this bug in Python 3.3 too? |
|||
| msg212393 - (view) | Author: Antoine Pitrou (pitrou) * | Date: 2014-02-27 22:54 | |
Is Python 3.3 still allowing bug fixes? If yes, this is a good idea. Do you want to backport it? |
|||
| msg212394 - (view) | Author: R. David Murray (r.david.murray) * | Date: 2014-02-27 23:04 | |
3.3 will get fixes until its final release, which will be some time after the release of 3.4.0. |
|||
| msg212395 - (view) | Author: Roundup Robot (python-dev) | Date: 2014-02-27 23:35 | |
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 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:59 | admin | set | github: 64990 |
| 2014-02-27 23:35:06 | python-dev | set | messages: + msg212395 |
| 2014-02-27 23:04:29 | r.david.murray | set | messages: + msg212394 |
| 2014-02-27 22:54:13 | pitrou | set | messages: + msg212393 |
| 2014-02-27 22:53:03 | vstinner | set | messages: + msg212392 |
| 2014-02-27 21:16:28 | pitrou | set | status: open -> closed resolution: fixed messages: + msg212389 stage: patch review -> resolved |
| 2014-02-27 21:16:04 | python-dev | set | nosy:
+ python-dev messages: + msg212388 |
| 2014-02-27 20:39:15 | peter.otten | set | messages: + msg212383 |
| 2014-02-27 19:27:29 | pitrou | set | versions:
- Python 3.3 nosy: + pitrou messages: + msg212377 stage: patch review |
| 2014-02-27 14:02:23 | r.david.murray | set | nosy:
+ r.david.murray messages:
+ msg212354 |
| 2014-02-27 13:35:08 | yselivanov | set | nosy:
+ yselivanov |
| 2014-02-27 09:46:57 | vstinner | set | nosy:
+ vstinner messages: + msg212345 |
| 2014-02-27 09:40:31 | peter.otten | set | files:
+ copy_bytes.patch nosy:
+ peter.otten keywords: + patch |
| 2014-02-27 08:58:03 | frankmillman | create | |