[Python-Dev] RE: cloning iterators again
Armin Rigo
arigo at tunes.org
Wed Oct 29 05:47:36 EST 2003
Hello Guido,
On Tue, Oct 28, 2003 at 10:00:14AM -0800, Guido van Rossum wrote:
> I haven't seen Armin's code, but I don't believe that the type alone
> gives enough information about whether they should be copied.
This is a quite deep problem, actually. I admit I have never used copy.py
because in all cases I needed more control about what should be copied or not.
This generator-copier module that we are talking about is no exception: its
existence is not only due to the fact that it can copy generators, but also
that I needed precise control over what I copied and what I shared. Putting
this information in __getstate__ or __copy__ methods of instances or in
copy_reg only goes so far, because sometimes you want to do different things
with the same instances in the same program -- e.g. you may want at some point
only a copy of a small number of objects (e.g. to be able to rollback a small
transaction), and at some other point a more complete copy of the state of the
same program.
Nevertheless, I can surely make a C module that registers in copy_reg a deep
copier for generators.
A bientot,
Armin.
More information about the Python-Dev
mailing list