A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-November/030029.html below:

[Python-Dev] Pickling Question

[Python-Dev] Pickling QuestionPatrick K. O'Brien pobrien@orbtech.com
Sat, 9 Nov 2002 08:46:55 -0600
On Saturday 09 November 2002 08:35 am, Guido van Rossum wrote:
> > I don't feel that this solution is entirely satisfactory and so I
> > thought I would ask (a bit late, I know) whether I am completely
> > correct in my assertions. If not, how else can this be handled. If
> > so, is there any chance of adding a better way to handle this
> > situation?
> >
> > [1] http://www-106.ibm.com/developerworks/library/l-pypers.html
>
> I don't believe a search-and-replace on a pickle can ever be safe. 
> In a binary pickle, it might interfere with length fields.  And in
> either kind of pickle, you might accidentally replace data that
> happens to look like a module name.

Yes. And that's why this was nagging me. I should have asked about it 
sooner.

> I'd suggest something else instead: when you have a pickle
> referencing module A which has since been renamed to B, create a
> dummy module A that contains "from B import *".  Then load the
> pickle, and write it back again.  The loading should work because a
> reference to class A.C will find it (as an alias for B.C); the
> storing should store it as B.C because that's the real name of class

I like this. Wish I had thought of it. Thanks.

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4