On Jan 24, 2008, at 9:25 PM, Alexandre Vassalotti wrote: > On Jan 24, 2008 9:47 AM, Jim Fulton <[EMAIL PROTECTED]> wrote: >> >> On Jan 23, 2008, at 4:30 PM, Alexandre Vassalotti wrote: >>> I am not sure what you mean by "cPickle.Pickler and >>> cPickle.Unpickler >>> subclassible in the same way as the pickle classes." It is >>> possible to >>> subclass the C implementation. However, the C implementation does >>> not >>> expose pickle "private" methods, such as Pickler.save_int and >>> Unpickler.load_tuple. This is fine because these were never >>> documented >>> as part of the interface of pickle. >> >> That doesn't mean that they aren't overridden. I've overridden them >> in specialized applications. I suspect that others have as well. >> > > Well even in pickle.py, you can't override the save_* and load_* > methods (at least, directly), since they are called via a dispatch > dictionary.
You have to override the dictionary too. :) >> I'm not really looking for anything that isn't there already. The >> python pickle version is more extensible that cPickle and I find that >> valuable. I don't want to make cPickle more flexible. I'd willing >> to >> trade off speed and flexibility depending on the application. I >> don't >> want to lose either in the interest of unification. > > How much of cPickle is really speed critical? cPickle is all about speed. > Personally, I think > built-in types pickling should be optimized as much as possible and > other things, such as user-defined classes and extension types > pickling, could be done in Python. The whole reduce dance should be in C, after all, it already is. Most user-defined types inherit the reduce method(s) provided by object, which is already written in C. >> Having said that, I would agree that there are certain aspects of >> their external APIs that ought to be unified. A good example is >> handling of globals. > > Could you elaborate about this, please; how the handling of globals by > cPickle is different from pickle? pickle.Unpickler has a find_class method that loads globals. This can be overridden in a subclass to provide alternate behavior. cPickle.Unpickler has a find_global attribute that can be assigned to provide alternate behavior. (Internally, a find_class C member is used for hysterical reasons. :) Jim -- Jim Fulton Zope Corporation _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
