[Python-3000] [Python-Dev] inst_persistent_id

Jim Fulton jim at zope.com
Tue Jan 22 16:30:27 CET 2008


On Jan 20, 2008, at 10:39 PM, Alexandre Vassalotti wrote:

> On Jan 20, 2008 4:14 PM, Jim Fulton <jim at zope.com> wrote:
>>
>> On Jan 12, 2008, at 7:33 PM, Alexandre Vassalotti wrote:
>>> By the way, you might be interested to look at my work on pickle [1]
>>> for Python 3K. As part of last year Summer of Code, I removed the
>>> differences between the Python and C implementation of pickle, and
>>> thus allowing the C version to be transparently used, instead of the
>>> Python one, when it is available.
>>
>> Interesting. Does that mean that cPickle can be extended through
>> inheritance?
>>
>
> Well, Pickler and Unpickler can be subclassed. I am not sure they can
> be really "extended," since, unlike the Python version, the C version
> of Pickler and Unpickler only exposes a minimal API.

Then I don't understand what you mean by:

"I removed the differences between the Python and C implementation of  
pickle, and thus allowing the C version to be transparently used,  
instead of the Python one, when it is available."

People *do* routinely subclass pickle.Pickler and pickle.Unpickler and  
if this isn't possible with cPickle, then it can't be substituted for  
pickle.  If making cPickle.Pickler and cPickle.Unpickler subclassible  
in the same way as the pickle classes makes cPickle much slower, then  
I don't think the "transparency" is worth the tradeoff.

...

> Well, I haven't changed cPickle much to make it subclassable. So, the
> impact is minimal. Currently, the only performance change is due the
> removal of the special-cases for PyFile and cStringIO "buffers."

What is the benefit of removing this special casing? What is the cost?

Jim

--
Jim Fulton
Zope Corporation




More information about the Python-3000 mailing list