Monday, June 3, 2013

NumPyPy status update

Hello everyone,

May was the first month I was paid to work on NumPyPy (thanks to all who donated!), here is what I worked on during this period :

  • It is now possible to use subarrays.
  • It is now possible to pickle ndarrays (including those using subarrays), dtypes and scalars, the pickling protocol is the same as numpy's.

For June, I plan to work on the nditer class, it seems that there's enough work for an entire month.

Cheers
Romain Guillebert

7 comments:

Anonymous said...

What's numpypy's recommended way for a C/cffi extension to get a pointer to the data?

Thanks,
Andreas

Anonymous said...

Excellent work!

Anonymous said...

Thanks! But pickling sliced arrays doesn't work yet (tested with nightly build pypy-c-jit-64739-f556942951f9-linux):

import cPickle as pickle
import numpypy as numpy
a = numpy.arange(10.)[::2]
print a # [ 0. 2. 4. 6. 8.]
p = pickle.dumps(a)
print pickle.loads(p) # [ 0. 1. 2. 3. 4.] oops!

Romain Guillebert said...

@Anonymous

Thanks for reporting it, it's fixed

Anonymous said...

Great to hear about the progress, keep up the good work!

Anonymous said...

It is working very well for me, thanks!

Now, is there any way to load the resulting pickle in cPython?

numpy.save and numpy.load do work between pypy and cPython, but my arrays are embedded in larger data structures.

The motivation is that I would like to run a numerical program and store some results, and then load the results and plot them with matplotlib (which does not work on pypy).

Here is the error in cPython:

>>> pickle.load(open('/tmp/x', 'r+b'))
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/pickle.py", line 1378, in load
return Unpickler(file).load()
File "/usr/lib/python2.7/pickle.py", line 858, in load
dispatch[key](self)
File "/usr/lib/python2.7/pickle.py", line 1090, in load_global
klass = self.find_class(module, name)
File "/usr/lib/python2.7/pickle.py", line 1124, in find_class
__import__(module)
ImportError: No module named _numpypy.multiarray

Anonymous said...

It is working great, thanks!

Now, is there any way to load the resulting pickle in cPython?

numpy.save and numpy.load do work between pypy and cPython, but my arrays are embedded in larger data structures.

The motivation is that I would like to run a numerical program and store some results, and then load the results and plot them with matplotlib (which does not work on pypy).

Here is the error in cPython:

>>> pickle.load(open('/tmp/x', 'r+b'))
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/pickle.py", line 1378, in load
return Unpickler(file).load()
File "/usr/lib/python2.7/pickle.py", line 858, in load
dispatch[key](self)
File "/usr/lib/python2.7/pickle.py", line 1090, in load_global
klass = self.find_class(module, name)
File "/usr/lib/python2.7/pickle.py", line 1124, in find_class
__import__(module)
ImportError: No module named _numpypy.multiarray