[Numpy-discussion] pickling ufuncs?

eric jones eric@enthought....
Sun Feb 11 23:19:52 CST 2007


I recently noticed that we can't pickle ufuncs (like sin, ...).  Is 
there any technical reason this doesn't work, or is it in the category 
of 'just needs to be done...'

FYI, I noticed that it didn't work on the old Numeric either.

thanks,
eric

Python 2.4.3 - Enthought Edition 1.0.0 (#69, Aug  2 2006, 12:09:59) [MSC 
v.1310
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import pickle
 >>> import numpy
 >>> import math
 >>> pickle.dumps(numpy.arange)
'cnumpy.core.multiarray\narange\np0\n.'
 >>> pickle.dumps(math.sin)
'cmath\nsin\np0\n.'
 >>> pickle.dumps(numpy.sin)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python24\lib\pickle.py", line 1386, in dumps
    Pickler(file, protocol, bin).dump(obj)
  File "C:\Python24\lib\pickle.py", line 231, in dump
    self.save(obj)
  File "C:\Python24\lib\pickle.py", line 313, in save
    rv = reduce(self.proto)
  File "C:\Python24\lib\copy_reg.py", line 69, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle ufunc objects
 >>>


More information about the Numpy-discussion mailing list