Re: Saving recursive objects to disc. cPickle wan't work.
Hi,
* Alex Polite <m4@polite.se > [26 May 2004 14:22:21 GMT]:[color=blue]
> I need to put recursive data structures on disc and found out that
> cPickle doesn't like recursion.[/color]
Hm, the documentation of Python 2.3.2, Section 3.14.1 "Relationsh ip to
other Python modules" states that recursive objects, which are defined
as "objects that contain references to themselves" can't be handled by
marshal, but that pickle and cPickle should be fine: "pickle stores
such objects only once, and ensures that all other references point to
the master copy".
Re: Saving recursive objects to disc. cPickle wan't work.
On ons, maj 26, 2004 at 04:34:00 +0200, Lutz Horn wrote:
[color=blue]
> Hm, the documentation of Python 2.3.2, Section 3.14.1 "Relationsh ip to
> other Python modules" states that recursive objects, which are defined
> as "objects that contain references to themselves" can't be handled by
> marshal, but that pickle and cPickle should be fine: "pickle stores
> such objects only once, and ensures that all other references point to
> the master copy".
>
> What exactly are your problems?[/color]
That sound promising.
I'm building a library to generate markov models from text, much like
dadadodo.
Re: Saving recursive objects to disc. cPickle wan't work.
Alex Polite wrote:
....
[color=blue]
> If I up the recusionlimit the testsuit will segfault.[/color]
Then you need a Python which does not have a stack problem.
Use Stackless Python. Just don't care of what else it does,
just use it, raise the recursionlimit to whatever,
and both pickle and cPickle will run without any limit but
main memory.
Well, almost true.
The current official version is unlimited on pickle.py,
becuase the recursive calls in pickle don't involve
recursive calls in the C interpreter.
Stack protection for cPickle is in my new developer version,
which is coming soon.
It has Stack spilling for cPickle and the interpreter, so
even in the rare cases where deep recursions cannot be avoided,
the Stack is always saved and restored before overflow.
And, well, I have full thread support since Monday :-))
ciao - chris
--
Christian Tismer :^) <mailto:tismer@ stackless.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
Re: Saving recursive objects to disc. cPickle wan't work.
On ons, maj 26, 2004 at 02:22:21 +0000, Alex Polite wrote:[color=blue]
> I need to put recursive data structures on disc and found out that cPickle
> doesn't like recursion.
>
> What are my options?
>
> alex[/color]
Christian Tismer had the kindness to look at my code and point out
that I might want to use pickle instead of cPickle, at least if I
wanted to benefit from using stackless. Chaning from cPickle to pickle
allowed to run the code under stackless as well as under standard
python.
cPickle bug (was: Saving recursive objects to disc. cPickle wan'twork)
Alex Polite wrote:[color=blue]
> On ons, maj 26, 2004 at 02:22:21 +0000, Alex Polite wrote:
>[color=green]
>>I need to put recursive data structures on disc and found out that cPickle
>>doesn't like recursion.
>>
>>What are my options?
>>
>>alex[/color]
>
>
> Christian Tismer had the kindness to look at my code and point out
> that I might want to use pickle instead of cPickle, at least if I
> wanted to benefit from using stackless. Chaning from cPickle to pickle
> allowed to run the code under stackless as well as under standard
> python.
>
> thanks Christian.[/color]
Although I'm happy that things work even without Stackless,
this implies that there is an incompatibility between
pickle and cPickle.
If objects are treated identically by both, that normal Python
must use even more stack space for recursive objects that
cPickle, so I'd expect it crashes earlier.
But it doesn't crash. cPickle must have a bug.
ciao - chris
--
Christian Tismer :^) <mailto:tismer@ stackless.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
Comment