[pypy-dev] Poor performance with custom bytecode
Timothy Baldridge
tbaldridge at gmail.com
Fri Feb 17 15:17:37 CET 2012
> First question - why did you choose to implement this as a compiler to
> python bytecode? It does sound like an interpreter written in rpython
> would have both a much better performance and a much easier
> implementation (compiler vs interpreter).
A few reasons for this. Mostly I didn't want to have to build up an
entire standard lib. Clojure is a bit unique in that it doesn't define
a standard library beyond the ~200 functions found in core.clj. This
means that Clojure leaves IO, GUI, etc, completely up to the VM. So
for stock Clojure this means you drop to Java interop whenever you
want to do IO. If, however, I develop the entire thing off of
CPython/pypy, I can use all the libraries for these platforms that are
already quite documented and stable. "Don't re-invent the wheel" is
more or less the mantra of Clojure implementation developers.
Long term though, I plan on implementing part (if not all) of
Clojure-py in RPython. This may be as simple as doing a pull request
to pypy asking to have my immutable structures adopted into the stock
VM, or I may attempt to build a from-scratch interpreter, we'll see.
So I guess it's like this: I could go with a custom VM, but when I'm
done, there's really not a whole lot my VM could do besides run
benchmarks. Even as clojure-py stands now, you could probably sit down
in one night and write a full blown Qt app via PySide with it, the
interop with Python is that good. So as it stands, we can write apps
with Django, PySide, numpy, etc. in Clojure and only after about 3
months worth of work!
The other thing that has been bugging me more and more lately, is what
benefit a RPython interpreter would get me. Besides Python's lack of
overloaded functions, there's really no features in Python I can't
find a use for in the Clojure compiler, and there's really nothing I'm
lacking in the pypy VM.
Timothy
More information about the pypy-dev
mailing list