[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"
too.

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
CPython.


_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to