Hi, I think what you need to add is a __reduce__ method. We have support for pickling array.array. Search for reduce in pypy/module/array/interp_array.py to get an idea of how it was implemented. If there are deeper issues that makes pickling more complicated for numpy arrays I dont know...
On Thu, Oct 6, 2011 at 6:55 AM, mike c <coolbutusel...@gmail.com> wrote: > Hi there, > I'm new to pypy and trying it out on some numerical projects and the speed > of pypy+numpy is about 4x faster than cpython+numpy. Pretty impressive! > However, I want to pickle some of my numpy objects and I get the > error: TypeError: can't pickle numarray objects (full error is included > below) > I realise that the numpy implementation in pypy is currently a > proof-of-concept, and so I was wondering what I would have to change to get > numarray's to be pickle-able. As simple as adding a something like a > __pickle__ method to numarray? Or is the problem deeper than that? > Mike. > > >>>>> import pickle, numpy >>>>> a = numpy.array([1,2,3]) >>>>> pickle.dumps(a) > Traceback (most recent call last): > File "<console>", line 1, in <module> > File "/Users/mike/pypy-1.6/lib-python/modified-2.7/pickle.py", line 1423, > in dumps > Pickler(file, protocol).dump(obj) > File "/Users/mike/pypy-1.6/lib-python/modified-2.7/pickle.py", line 224, > in dump > self.save(obj) > File "/Users/mike/pypy-1.6/lib-python/modified-2.7/pickle.py", line 306, > in save > rv = reduce(self.proto) > File "/Users/mike/pypy-1.6/lib-python/2.7/copy_reg.py", line 70, in > _reduce_ex > raise TypeError, "can't pickle %s objects" % base.__name__ > TypeError: can't pickle numarray objects > > > > _______________________________________________ > pypy-dev mailing list > pypy-dev@python.org > http://mail.python.org/mailman/listinfo/pypy-dev > > -- Håkan Ardö _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev