[C++-sig] float data pickling issue

Grant gtang at bcm.edu
Sun Sep 16 17:53:08 CEST 2007


Hi,

I have a class which has a float array. I write the pickling support for
this class by following boost.python's way and it works fine. But the thing
is the object size after pickling is about twice as I expect. Apparently
the float is saved as double when pickling. I checked the python API, there
are functions in floatobj.h like: _PyFloat_Pack4() and _PyFloat_Unpack4().
If these are functions I need to pickle float as four bytes, How can I do?
Or is there any other way to accomplish this (pickle float as four bytes
other than double)?

Thanks in advance,
Grant




More information about the Cplusplus-sig mailing list