[ale] python pickle data types

Matt Kubilus mattkubilus at gmail.com
Thu Oct 25 00:17:16 EDT 2007


It's not that you are pickling a non-standard data type.  You should
be able to pickle pretty much any *python* object.

It appears that python has no way of knowing what is inside
private/protected parts of C/C++ extension classes.  This kind of
makes sense.  It appears you may have to either add something to the C
class or extend it in python.  This is what a cursory glances shows:

http://osdir.com/ml/programming.swig/2003-03/msg00061.html

An alternate method may be to extract the data parts from the object
and create a method that can load & save this data.  I'm making the
assumption that there is some kind of useful interface to these
classes.  I'm not really sure what you are doing, so I'm going out on
a limb here.

-Matt

On 10/24/07, Jim Popovitch <yahoo at jimpop.com> wrote:
> I've got a python problem, and Google isn't helping me much (could be
> because I am looking for something much saner that what Google searches
> suggest....)
>
> I'm using an existing SWIG data type (from someone else's code+library)
> like so:
>
>         b = blahGetBigBlobOfData()
>         with open('/tmp/buffer', 'wb') as f:
>                 pickle.dump(b,f)
>
> When run, I get this error:
>
>   File "/usr/lib/python2.5/copy_reg.py", line 69, in _reduce_ex
>     raise TypeError, "can't pickle %s objects" % base.__name__
>  TypeError: can't pickle PySwigObject objects
>
>
> So I did a bunch of Google searches on the error, but none seem to
> explain a straigh forward way to insert (possibly via type casting) a
> non-standard data type into a pickle.
>
> Any ideas?
>
> Thanks!
>
> -Jim P.
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>


-- 
Don't be a pioneeer.  A pioneer is the guy with the arrow through his
chest.  -- John J. Rakos



More information about the Ale mailing list