> I read the new PEP about pickling with much interest and little > comprehension. I'd like to comment then just by saying what I wish I could > do and invite response as to whether the PEP will help do it. > > I would like to be able to: > > Save and restore a class definition > Save and restore a function definition Alas, that ground is specifically not covered by pickling -- not in the past and not now. This is by design. Pickling was designed for data, and when the data contains a reference to a class or function, that reference is specifically excluded from the pickling; instead, the pickler says "here's a reference to class C (or function f) in module M"; the unpickler imports module M, finds C or f in it, and inserts that in the unpicked data. But you're not the only one to want to save and restore classes and functions. Jeremy Hylton has gone through heroic efforts to make this possible in Zope 3, by subclassing the Pickler and Unpickler classes. Maybe he can tell you more. --Guido van Rossum (home page: http://www.python.org/~guido/)
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