[Tino Wildenhain]
> ...
> Btw, (hijacking the thread because a bit related) how can I serialize the
> state of a generator object? (e.g. for caching it between requests)
> Pickle does not work for it (whyever)

You cannot.  A generator-iterator contains (among other things) a Python
stack frame, and you can't even serialize one of those by itself (let alone
a generator containing one).  For that matter, a Python stack frame contains
a Python code object and a Python thread state, which latter includes
addresses of C functions and a Python interpreter state, which in turn
contains a linked list of Python thread states ... there's nothing on Earth
_less_ serializable than a generator ;-).  That goes beyond "serializing
code" to "serializing code and its current execution state in midstream"

It's possible that PyPy will (or already has) a kind of object space in
which this is possible, but I don't except it will ever be possible in

For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to