Pickling extension types

Robert Kern robert.kern at gmail.com
Wed May 4 14:30:36 EDT 2011


On 5/4/11 10:45 AM, Stefan Kuzminski wrote:
> I got this to work by returning from reduce just the args that the __init__ of
> the type being pickled requires ( rather than the 5 length tuple described in
> the pickling docs ), I am not going to argue with it though..

Let's take a step back. The documentation says to return a tuple between 2 and 5 
elements long. You can omit the optional ones or use Nones in their place. The 
original code you posted allocated a 5-tuple, but did not insert anything into 
positions 2, 3, or 4. This was an error. You should have returned a 2-tuple of 
the type object in the 0-index slot and the argument tuple in the 1-index slot. 
Are you saying that you just returned the argument tuple? I don't think that 
would work.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list