Iterative version of Python deepcopy

Is there an existing implementation of the iterative version of deepcopy for Python 2.5.2? The deepcopy method, accessible from the copy module, is recursive and does not work on large trees. I am not in a position where we can safely increase the stack limit at runtime.

EDIT

I traced this:

http://code.activestate.com/recipes/302535/

I have not tested it, but it looks like it has potential.

+4
source share
2 answers

I am not sure if this will make sense. Isn't it all the deepcopy point that every object asks its children to copy itself?

Presumably, you know exactly what kind of object you are copying and what its children look like, so if I were you, I would just write my own function to copy it. It should not be too complicated.

+1
source

Maybe it will work as such with Stackless Python

0
source

All Articles