Multiprocessing, shared memory vs. pickled copies

Robert Kern robert.kern at gmail.com
Thu Apr 7 19:44:05 CEST 2011


On 4/7/11 1:40 AM, John Ladasky wrote:

> On Apr 5, 10:43 am, Philip Semanchuk<phi... at semanchuk.com>  wrote:

>> And as Robert Kern pointed out, numpy arrays are also pickle-able.
>
> OK, but SUBCLASSES of numpy.ndarray are not, in my hands, pickling as
> I would expect.  I already have lots of code that is based on such
> subclasses, and they do everything I want EXCEPT pickle correctly.  I
> may have to direct this line of questions to the numpy discussion
> group after all.

Define the __reduce_ex__() method, not __getstate__(), __setstate__().

http://docs.python.org/release/2.6.6/library/pickle.html#pickling-and-unpickling-extension-types

ndarrays are extension types, so they use that mechanism.

-- 
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