[Stackless] Pickling and recursion

lars van Gemerden lars at rational-it.com
Wed Oct 3 13:43:59 CEST 2012


Hi Kristjan,

Thanks for your response, it is somewhat clearer now. However I have some
more questions about the subject (because some of my data structures are
very recursive and redesigning them would be a lot of work):

- under what conditions can stackless mitigate these recursion limits (for
pickle and cPickle, what do i need to avoid)?
- does this mitigation circumvent pythons recursion limit or does it only
kick in after the python recursion limit has been disabled?
- i am working on stackless python 2.7, what are the differences with
stackless python 3 in this respect?
- What happens if i write my own highly recursive persistence module (i
wrote one that converts most python objects to XML via the etree module)?

This is far from the only reason I use stackless, but it would be a great
bonus if i could be reasonable sure that i won't run into recursion
problems in the near future (this has been one of those nagging
uncertainties in the back of my mind).

Cheers, Lars



On Tue, Oct 2, 2012 at 11:34 AM, Kristján Valur Jónsson <
kristjan at ccpgames.com> wrote:

> Not necessarily.
> the term "stackless" is historic in this respect.  Originally, the attempt
> was made to have pure python code work independently of the C stack.
> In practice, this change was simply too big to be maintainable and so,
> nowadays, stackless does try to do this when possible, but otherwise
> relents.
> Pickling in version 3 of python is by default done using C code, and C
> code normally also uses the c stack for recursion.
>
> Two opposite caveats exists:
> 1) Stackless does attempt to mitigate C recursion by using "stack
> spilling" where very deep c invocation stacks are stored away on the heap.
>  This process is not foolproof and can become degenerated, but it is
> designed to work with regular python function invocation and pickling.
> 2) Python imposes its own recursion limit.  This has to be disabled to go
> very deep.  But again, this does not apply to c pickling.
>
> So no, stackless python does not promise stackless python evaluation in
> the literal sense, but it might help you for very deep pickling.  Since it
> is not the primary purpose of Stackless, your mileage may vary.
> K
>
> > -----Original Message-----
> > From: stackless-bounces at stackless.com [mailto:stackless-
> > bounces at stackless.com] On Behalf Of Lars van Gemerden
> > Sent: 1. október 2012 08:16
> > To: stackless at stackless.com
> > Subject: [Stackless] Pickling and recursion
> >
> > Hello,
> >
> > I was wandering whether using stackless also means that there is
> (practically)
> > no limit to the recursion depth of highly recursive objects when using
> > pickle/cPickle?
> >
> > Cheers, Lars
> >
> > ====================================
> > Lars van Gemerden
> > lars at rational-it.com
> > +31 6 26 88 55 39
> > ====================================
> > _______________________________________________
> > Stackless mailing list
> > Stackless at stackless.com
> > http://www.stackless.com/mailman/listinfo/stackless
>
>
>
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless
>



-- 
====================================
Lars van Gemerden
lars at rational-it.com
+31 6 26 88 55 39
====================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20121003/cd43fcb9/attachment.html>


More information about the Stackless mailing list