To match the inline behavior copy.deepcopy, you must use the idobject as a key.
More details:
Although you often manage to avoid using another key scheme (for example, the object itself, if it hashable), if you agree, you can still run into problems. Often __deepcopy__implemented by calling copy.deepcopyfor some contained attributes. If you add elements directly to memo, you must be sure that the keys will not collide with the elements added copy.deepcopy, which adds the keys generated idthat are integers.
So, if you use a different key scheme, for example, using objects directly as keys, you can never add whole objects.
:
id .