Calling A Python File Within Pypy
Solution 1:
You can't expect to import modules and have them co-exist in the same program which would be running half CPython and half PyPy. However, what you can do is to run your program mainly in one of the two interpreters, and consider the other one as an additional library with which you communicate at a lower level than with Python objects.
For example, if you only want to use matplotlib to display some graphic, you can from PyPy start a CPython program (with os.system()
or the subprocess
module) and pass it the data to display in one way or another (e.g. by sending it into a pipe). If this is too limiting for what you want, there are other alternatives which are more involved. You can for example load libpython2.7.so
inside PyPy and call its C API with CFFI. Or the reverse: embed PyPy inside CPython (as e.g. http://jitpy.readthedocs.org/en/latest/ ).
Solution 2:
You can't run (or import) python scritps that need modules not supported by pypy.
You actually can use matplotlib from within pypy, but it's very very hackish (and hard to do).
The simple answer here is just use plain python. If you're doing numeric manipulation, all intensive code should be inside numpy
, anyway.
Post a Comment for "Calling A Python File Within Pypy"