pickle vs .pyc

Michael Vezie mlv at pobox.com
Wed Jun 2 23:06:13 EDT 1999

In article <m3pv3eian1.fsf at atrus.jesus.cam.ac.uk>,
Michael Hudson  <mwh21 at cam.ac.uk> wrote:
>Hmm, you're relying on all the data you're storing having faithful
>__repr__ methods. This certainly isn't universally true. I'd regard
>this method as too fragile.

Granted.  It wouldn't do for the file to contain:

fast = <__main__.fast instance at 8137590>
slow = <__main__.slow instance at 8137590>

But the data I'm dealing with is all dictionaries of arrays of dictionaries, 
all containing strings.  Pretty boring; no class at all.

>If you're only storing simple data (by which I mean simple types of
>data, not that the data is simple) (and I think you must be for the
>approach you're using to work) give the marshal module a whirl.

This is the first I've heard of marshal.  I take it from various 
hints here and there that the .pyc files are handled internally 
by marshal, yes?

Thanks for your (and everyone else's) help.

One final asside, I've seen disagreements both online and in the 
web docs about the spelling of marshal.  I did a search and found 
12 hits for "marshall" (now granted, some are probably unrelated, I 
didn't trace them all).  But there were enough to make me think 
that 'marshall' was the right spelling.

But the fact that 'import marshal' worked while 'import marshall' 
failed convinced me otherwise.  :)

marshaling-up-the-courage-to-convert-working-code-to-marshal'ly yrs

... (hoping-this-'ly yrs-tag-isn't-trademarked-or-only-available-
to-those-who've-achieved-some-level-of-pythondom'ly yrs)


More information about the Python-list mailing list