This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: More efficient deepcopying of Mapping
Type: resource usage Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-06-07 17:35 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
MappingView_deepcopy.patch serhiy.storchaka, 2016-06-07 17:35 review
Messages (2)
msg267706 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-07 17:35
Mapping views supports copying and deepcopying by default (using pickle protocol). But copy.deepcopy() is not efficient for KeysView and ValuesView. It copies all keys and values, while KeysView needs copying only keys and ValuesView needs copying only values.

Proposed patch implements more efficient deepcopy support for KeysView and ValuesView.
msg267755 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-06-08 00:10
Is this ever needed?  I'm not sure whether all these patches are being driven by reasonable use cases or whether it is just something that could be done.

I thought the whole point of the views was to avoid copying.  If so, there is a design principle that says roughly, "take things you want users to do and make them easy and fast, while leaving undesirable patterns in a less comfortable state".  We don't have to break the copying and deepcopying, but we don't need to go out of our way to make them more efficient unless that is what we want users to be doing.
History
Date User Action Args
2022-04-11 14:58:32adminsetgithub: 71440
2016-06-26 21:41:52serhiy.storchakasetstatus: open -> closed
resolution: rejected
stage: patch review -> resolved
2016-06-08 00:10:06rhettingersetmessages: + msg267755
2016-06-07 17:35:12serhiy.storchakacreate