Pickling generators, why not? (was Re: Scheme style and Python style [was: Re: Typed Python?]
pinard at iro.umontreal.ca
Tue Jul 13 20:57:34 CEST 2004
> [François Pinard]
> > Suddenly backtracking out of a complex involvement for restarting
> > in a new direction, for the above project at least, requires a lot
> > of state resumption, and doing this cleanly in Python implies a
> > rather strict and burdening discipline about where and how the state
> > information is kept.
> Would such a problem be solvable if you could pickle a "running"
Not really. Generators could be used in chains (of generators), each
element of the chain usually being some local variable in another
element, and pickling one is meaningless if you cannot pickle them
all. Moreover, the serialisation implied by pickling would usually be
extraneous and unwanted overhead to the whole process of saving and
restoring generator state.
> So, is there some deep philosophical (as opposed to implementation
> detail) flaw in the picklable generator idea?
I'm not a deep philosopher, so I cannot say! :-)
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list