[Numpy-discussion] object array binary pickling and nan

Andrew Straw strawman at astraw.com
Fri Jul 28 14:28:25 CDT 2006

Tom Denniston wrote:

>Code that reproduces the problem:
>This is regular python:
>pickle.dumps(numpy.nan, 2)
>SystemError: frexp() result out of range
>This is fine in numpy:
>pickle.dumps(numpy.array([numpy.nan]), 2)
>This breaks:
>pickle.dumps(numpy.array([numpy.nan], numpy.PyObject), 2)
>SystemError: frexp() result out of range
It seems to me that the example that shows what you want is the only
example that numpy has control over, anyway. In the other two cases,
you're really using a Python object.

So it's really a Python question as to why it can't pickle nans. My
understanding on this is weak, but here's one summary, albeit dated:
http://www.python.org/dev/summary/2000-10-1.html Here's something more
recent: http://mail.python.org/pipermail/python-list/2005-July/290272.html

NumPy sidesteps these issues by "forcing" IEEE-754 behavior with clever
C written AFAIK by the numarray people. These apparently work even if
the C compiler doesn't "officially" support IEEE-754, but it's not going
to work on every platform that Python targets.

You may also want to take a look at

More information about the Numpy-discussion mailing list