[Python-Dev] Re: removing inst_persistent_id from pickle (original) (raw)
Jim Fulton jim@zope.com
Wed, 13 Nov 2002 11:42:48 -0500
- Previous message: [Python-Dev] removing inst_persistent_id from pickle
- Next message: [Python-Dev] logging docs needed
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jeremy Hylton wrote:
Pickle and cPickle have an undocumented hook called instpersistentid(). When Barry updated the pickle documentation (round about the 2.2 release), no one could figure out what it did. I think we've figured out what it does, finally, but I think we should get rid of it before someone tries to use it.
The pickler has a hook for handling persistent objects. The hook basically allows objects to be pickled by reference to some mechanism external to the pickler. The pickler gets a persistentid() function that returns the external reference. The unpickler needs a persistentload() function that returns the object given the reference from persistentid(). This process is fairly general, although the only use I'm familiar with is ZODB. The instpersistentid() hook seems to be designed for a very special case -- that the persistentid() function returns an object that is unpicklable. The function is only called when the pickler encounters an object that it hasn't handled via persistentid() or the dispatch table. The object returned by instpersistentid() is always passed to savepers(), just like persistentid(). We imagine the intended control flow is: - pickler created in binary mode - persistentid() returns an unpicklable object - instpersistentid() is called to convert this to a picklable object I don't think this odd case is worth the added complexity, particularly since the hook function probably won't be called for a text-mode pickler. Anyone object to its removal?
No. In fact, I endorse it's removal.
Jim
-- Jim Fulton mailto:jim@zope.com Python Powered! CTO (888) 344-4332 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org
- Previous message: [Python-Dev] removing inst_persistent_id from pickle
- Next message: [Python-Dev] logging docs needed
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]