[pypy-dev] pickle numpy array from pypy to cpython?
matti picus
matti.picus at gmail.com
Sat Jun 25 00:19:43 EDT 2016
Sounds reasonable. You might want to generalize it a bit by trying to
import _numpypy /numpy, and setting up the replacement by whichever fails
to import.
Matti
On Saturday, 25 June 2016, Eli Stevens (Gmail) <wickedgrey at gmail.com> wrote:
> Heh, interestingly, if I add the following to the local dir and files
> when trying to unpickle under cpython, it works (note that cpython to
> pypy actually works out of the box, which I hadn't realized):
>
> $ cat _numpypy/__init__.py
> from numpy.core import *
>
> $ cat _numpypy/multiarray.py
> from numpy.core.multiarray import *
> import numpy.core.multiarray as _ncm
> _reconstruct = _ncm._reconstruct
>
> This is obviously a total hack, and not one I'm comfortable with
> (since I need to use this codebase from both cpython and pypy), but it
> demonstrates that it's just bookkeeping that needs to change to get
> things to work.
>
> My first approach would be to add a wrapper around save_global here
>
> https://bitbucket.org/pypy/pypy/src/a0105e0d00dbd0f73d06fc704db704868a6c6ed2/lib-python/2.7/pickle.py?at=default&fileviewer=file-view-default#pickle.py-814
> that special-cases the global '_numpypy.multiarray' to instead be
> 'numpy.core.multiarray'. That seem like a reasonable thing to do?
>
> Cheers,
> Eli
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20160625/9e3c6d60/attachment.html>
More information about the pypy-dev
mailing list