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

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])