[pypy-dev] C interpreter written in Python, and running CPython on top of PyPy

lahwran blendmaster1024 at gmail.com
Fri Jan 6 16:23:28 CET 2012

Perhaps take a look at how https://github.com/albertz/PyCParser does
it? I've never touched the project, but it sounds like exactly what
you're describing.

On Fri, Jan 6, 2012 at 7:59 AM, Celil <celil.kj at gmail.com> wrote:
> I have been thinking about the possibility of creating a C interpreter in
> Python.
> Is anybody already working on that? With PyPy this would presumably be quite
> easy to do. The interpreter will load the C code, create an AST (presumably
> using pyparsing and the EBNF spec of the C-language), and then populate the
> Flow Object Space with all the C objects, and create a control flow graph of
> the application logic. This graph will containe low level lltype objects,
> and can then be directly connected to the RPython flow-graph generated after
> the RTyper step. This would allow for seamless interoperability between C
> and PyPy, and would also greatly simplify the task of porting existing
> CPython extensions such as numpy.  Rather than going through the error prone
> task of translating the whole code base into RPython, one will be able to
> simply load the exiting C source code and integrate it directly into the
> RPython flow graph. It will be possible to import *.h and *.c files directly
> without any compilation, and they will run nearly as fast thanks to PyPy's
> JIT technology.
> This would also allow us to do things like running CPython on top of PyPy.
> Right now it is possible to run PyPy on top of CPython, but the reverse is
> not. If CPython could be run on top of PyPy by interpreting its C source
> code that would be truly amazing. Interpreting C code would greatly help
> CPython developers by freeing them from the task of having to repeatedly
> compile their code.
> Celil
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> http://mail.python.org/mailman/listinfo/pypy-dev

More information about the pypy-dev mailing list