8000 Skip deepcopy memo check when memo is empty · Issue #109868 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Skip deepcopy memo check when memo is empty #109868
Closed
@eendebakpt

Description

@eendebakpt

Feature or enhancement

Proposal:

In the copy.deepcopy method we can skip the initial memo check if the memo was just created. We can replace

    if memo is None:
        memo = {}
    d = id(x)
    y = memo.get(d, _nil)
    if y is not _nil:
        return y

with

    d = id(x)
    if memo is None:
        memo = {}
    else:
        y = memo.get(d, _nil)
        if y is not _nil:
            return y

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagestdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0