Skip to content
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

Make dict views copyable #71439

Closed
serhiy-storchaka opened this issue Jun 7, 2016 · 5 comments
Closed

Make dict views copyable #71439

serhiy-storchaka opened this issue Jun 7, 2016 · 5 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 27252
Nosy @gvanrossum, @rhettinger, @serhiy-storchaka
Files
  • dict_views_copy.patch
  • 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:

    assignee = None
    closed_at = <Date 2016-06-26.21:41:58.364>
    created_at = <Date 2016-06-07.16:27:29.648>
    labels = ['type-feature', 'library']
    title = 'Make dict views copyable'
    updated_at = <Date 2016-06-26.21:41:58.363>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-06-26.21:41:58.363>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-06-26.21:41:58.364>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2016-06-07.16:27:29.648>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['43280']
    hgrepos = []
    issue_num = 27252
    keywords = ['patch']
    message_count = 5.0
    messages = ['267701', '267703', '267713', '267717', '267756']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'rhettinger', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27252'
    versions = ['Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    Proposed patch adds support of dict views in the copy module.

    Since dict views are immutable, copy.copy() just returns the same object.

    copy.deepcopy() returns a frozenset for the dict_keys object, a tuple for the dict_values object, and a dict_items object for the dict_items object. Only needed data is copied (keys for dict_keys, values for dict_values).

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 7, 2016
    @gvanrossum
    Copy link
    Member

    I'm still not clear about the use case -- have you heard from people who had to work around the current situation? Use of the copy module is often a code smell in my experience, so I don't want to encourage it.

    @serhiy-storchaka
    Copy link
    Member Author

    I didn't encounter this.

    @rhettinger
    Copy link
    Contributor

    I think we should stop adding features like this without actual user requests and real use cases to show necessity and to inform the design.

    @rhettinger
    Copy link
    Contributor

    See also: http://bugs.python.org/issue27253

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants