Skip to content

[deepcopy] Support passing some additional classes to be considered for atomic deepcopy #141737

@rupika-sinha

Description

@rupika-sinha

Feature or enhancement

Proposal:

I often run into use-cases where I'm using external libraries that might have/use some immutable objects. In this case I can't use deepcopy() on these objects or other structures that have them nested. Again, since these are external libraries, I cannot easily add a __deepcopy__ implementation for it.

In these cases it would be helpful to have some support to pass some custom Classes to deepcopy which it should treat as atomic types. Or a non-monkey-patched alternative to adding onto the _deepcopy_dispatch.

Is it possible to support something like this? Or maybe I'm missing something and this can already be done.

Expectation: hopefully something like this --

my_copy = deepcopy(element_to_copy, atomic_types=[SomeImmutableType])

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions