no pickling code objects?

holger krekel pyth at devel.trillke.net
Thu May 9 18:36:37 EDT 2002


Steve Holden wrote:
> "Gonçalo Rodrigues" <op73418 at mail.telepac.pt> wrote ...
> > Hi,
> >
> > On the docs on the pickle module it says that code objects can not be
> > pickled, this in turn implies some limitations on the pickleability
> > (man, I like this word!) of some objects. The docs mention security
> > reasons for this choice. But somehow this doesn't feel right. Shouldn't
> > the secuity concerns be left to the programmers? After all Python
> > already has exec*. Is there something I am missing?
> >
> > I am asking this mainly from curiosity, I am in no need of such a
> > feature. And then again, If I had the time and the knowedge + skill to
> > come up with a patch...
> >
> 
> One issue which nobody yet seems to have addressed is that code objects
> change from version to version. So even if you could work out where the
> dependency chain ended, the data (pickled code) would be useless in the next
> major version.

I think it would be *a feature* that you unpickle objects together with 
their code.  Because the unpickled code is likely to be able to access 
it's state in a well-behaved manner.

Upgrading versions is a quite fundamental problem in *any* software system. 
But i think it is easier to 

- initialize your new code by iterating over specific 'old' unpickled objects

- asking some of these objects to deliver relevant state and

- transfering/transforming to the state of the new code.

Note that without pickled code you need to always 
know exactly *the data structure* of the older version and it 
is difficult to get the 'unpickle.load' right.

longing-for-code-pickely y'rs holger





More information about the Python-list mailing list