to py or not to py ?

Robert Kern robert.kern at gmail.com
Wed Jun 28 03:47:21 EDT 2006


Chandrashekhar kaushik wrote:
> pyton does allow this using cPickle , but it bloats the data like 
> anythin !!!
> for example a class containing 2 integers which i expect will be 8 bytes 
> long ..
> cPickle.dumps returns a string thats 86 bytes wide !!!! ( this is the 
> binary version protocol 1 )
> 
> anyway to improve serialization ??

Use protocol 2. Also, since it looks like you will be dealing with homogeneous 
arrays of numerical data, you should think about using numpy to store that data. 
With protocol 2, cPickle only adds 129 bytes per array no matter the size.

   http://www.scipy.org/NumPy

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