[pypy-dev] pickle numpy array from pypy to cpython?

Eli Stevens (Gmail) wickedgrey at gmail.com
Fri Jun 24 15:43:12 EDT 2016


Yeah, looks like that's still the case:

>>>> z = np.zeros((2,3), dtype=np.float32)
>>>> z.tofile
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'numpy.ndarray' object has no attribute 'tofile'

What would it take to get cross-interpreter numpy array pickles working?

Thanks,
Eli

On Thu, Jun 23, 2016 at 10:14 PM, David Brochart
<david.brochart at gmail.com> wrote:
> Last time I tried tofile and fromfile in Numpypy it was not implemented.
>
> On Fri, Jun 24, 2016 at 7:01 AM, Eli Stevens (Gmail) <wickedgrey at gmail.com>
> wrote:
>>
>> No, since it's not *just* a numpy array I need to move around (dict
>> with numpy values, in this case, more complicated objects in the
>> future). Obviously I can kludge something manual together (assuming
>> the tofile/fromfile functions work cross-interpreter, which I wouldn't
>> take for granted at this point), but I'd rather be able to use pickle
>> (easier to work with libraries that also expect pickles, etc.).
>>
>> Eli
>>
>> On Thu, Jun 23, 2016 at 7:54 PM, William ML Leslie
>> <william.leslie.ttg at gmail.com> wrote:
>> > On 24 June 2016 at 12:14, Eli Stevens (Gmail) <wickedgrey at gmail.com>
>> > wrote:
>> >> I'm trying to construct some data that includes numpy arrays in pypy,
>> >> pickle it, then unpickle it in cpython (to use some
>> >> non-pypy-compatible libs).
>> >>
>> >> However, the actual class of the pickled array is _numpypy.multiarray,
>> >> which cpython doesn't have.
>> >>
>> >> Any suggestions?
>> >
>> > Have you considered the tofile method and fromfile function?
>> >
>> >
>> > http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tofile.html#numpy.ndarray.tofile
>> >
>> >
>> > http://docs.scipy.org/doc/numpy/reference/generated/numpy.fromfile.html#numpy.fromfile
>> >
>> > --
>> > William Leslie
>> >
>> > Notice:
>> > Likely much of this email is, by the nature of copyright, covered
>> > under copyright law.  You absolutely MAY reproduce any part of it in
>> > accordance with the copyright law of the nation you are reading this
>> > in.  Any attempt to DENY YOU THOSE RIGHTS would be illegal without
>> > prior contractual agreement.
>> _______________________________________________
>> pypy-dev mailing list
>> pypy-dev at python.org
>> https://mail.python.org/mailman/listinfo/pypy-dev
>
>


More information about the pypy-dev mailing list