Author kristjan.jonsson
Recipients kristjan.jonsson, loewis, michael.foord
Date 2012-03-13.16:10:11
SpamBayes Score 3.71475e-12
Marked as misclassified No
Message-id <1331655020.29.0.612944465478.issue14288@psf.upfronthosting.co.za>
In-reply-to
Content
A common theme in many talks last year about cloud computing was the need to suspend execution, pickle state, and resume it on a different node.  This patch is the result of last year's stackless sprint at pycon, finally completed and submitted for review.

Python does not currently support pickling of many run-time structures, but pickling for things like iterators is trivial.
A large piece of Stackless' branch is to make sure that various run-time constructs are pickleable, including function objects.  While this patch does not do that, it does add pickling for dictiter, and the lot.
This makes it possible to have compilcated data sets, iterate through them, and pickle them in a semi-consumed state.

Please note that a slight hack is needed to pickle some iterators.  Many of these classes are namely "hidden" and there is no way to access their constructors by name.  instead, an unpickling trick is to invoke "iter" on an object of the target type instead.  Not the most elegant solution but I didn't want to complicate matters by adding iterator classes into namespaces.  Where should stringiter live for example?  Be a builtin like str?

We also didn't aim to make all iterators copy.copy-able using the __reduce__ protocol.  Some iterators actually use internal iterators themselves, and if a (non-deep) copy were to happen, we would have to shallow copy those internal objects.  Instead, we just return the internal iterator object directly from __reduce__ and allow recursive pickling to proceed.
History
Date User Action Args
2012-03-13 16:10:24kristjan.jonssonsetrecipients: + kristjan.jonsson, loewis, michael.foord
2012-03-13 16:10:20kristjan.jonssonsetmessageid: <1331655020.29.0.612944465478.issue14288@psf.upfronthosting.co.za>
2012-03-13 16:10:19kristjan.jonssonlinkissue14288 messages
2012-03-13 16:10:19kristjan.jonssoncreate