0

I'm looking to port an existing interpreted language to RPython (the system underlying pypy), but I need to keep the ability to run the interpreted language in CPython.

Is the RPython interpreter (rlib?) available as a CPython module? Alternatively, is it reasonable to use pypy to generate C code which I can access using ctypes/cython?

amwinter
  • 3,121
  • 2
  • 27
  • 25
  • If you’re looking to do it for performance reasons, there’s also Cython, which compiles annotated Python code down to C in a way that interoperates with Python code as if it had not been compiled to C. – icktoofay Aug 23 '15 at 20:06
  • @icktoofay RPython traces the execution of the interpreted DSL and can optimize repeated executions. It's also 'designed for' hosting interpreters, so I'm hoping to get some lines-of-code savings that I wouldn't get from Cython. – amwinter Aug 23 '15 at 20:12

2 Answers2

1

Maybe not what you mean, but RPython is a subset of Python. If you start with an interpreter written in Python and manage to convert it to RPython, then it will continue to run in Python too, like it did before.

On the other hand, if you want to translate your interpreter to C but at the same time run the resulting C code together with CPython, then it is possible to give your interpreter some C API. This makes the result of translation a regular C library, which you can access as usual by writing a CPython C extension module (or using cffi, or Cython, etc.).

Armin Rigo
  • 12,048
  • 37
  • 48
0

oops, nevermind:

https://pypi.python.org/pypi/rpython/0.1.4

The pypy team maintains an rpython library on PyPI.

amwinter
  • 3,121
  • 2
  • 27
  • 25