Jeremy Hylton wrote: > Pickle and cPickle have an undocumented hook called > inst_persistent_id(). 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 persistent_id() function > that returns the external reference. The unpickler needs a > persistent_load() function that returns the object given the reference > from persistent_id(). This process is fairly general, although the > only use I'm familiar with is ZODB. > > The inst_persistent_id() hook seems to be designed for a very special > case -- that the persistent_id() function returns an object that is > unpicklable. The function is only called when the pickler encounters > an object that it hasn't handled via persistent_id() or the dispatch > table. The object returned by inst_persistent_id() is always passed > to save_pers(), just like persistent_id(). > > We imagine the intended control flow is: > > - pickler created in binary mode > - persistent_id() returns an unpicklable object > - inst_persistent_id() 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
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