Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4642

Re: Pickling extension types

From Robert Kern <robert.kern@gmail.com>
Subject Re: Pickling extension types
Date 2011-05-04 13:30 -0500
Organization The Church of Last Thursday
References <BANLkTi=sUu_VFKrW+KSk8-RDzr5vgSLKqQ@mail.gmail.com> <ippu74$199$1@dough.gmane.org> <BANLkTin_8569Lk-s9y-6Vhb=47628hxsVQ@mail.gmail.com> <iprq2b$pp5$1@dough.gmane.org> <BANLkTimSgQs0YChMfN4HGBnFT8N+P4dJng@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1164.1304533849.9059.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Pickling extension types Robert Kern <robert.kern@gmail.com> - 2011-05-04 13:30 -0500

csiph-web