[pypy-dev] Poor performance with custom bytecode

Timothy Baldridge tbaldridge at gmail.com
Fri Feb 17 16:11:55 CET 2012

> A more generally targeted question, besides the sample rpython tutorial for
> brainfuck, what are the recommended readings (parts of the pypy code,
> papers, etc), tools and/or magic for working at rpython on an interpreter?

Now, most of this code is more or less crap, but I do suggest taking a
look at my first stab at a RPython interpreter for Clojure


IIRC, the target complied okay, and you could run the code in scratchspace.clj.

Basically I got to the point where I realized that if I had lisp
macros, I could write RPython code way faster. Half of the structures
in Clojure follow this pattern:

class Foo(object):
    def __init__(self, foo bar, baz):
         self.foo = foo
         self.bar = bar
         self.baz = baz
    def addBarBaz(self):
         return bar + baz

I could write that for that, or, in Clojure I could write myself a
macro and just do:

(deftype Foo [foo bar baz]
      (addBarBaz[self] (+ bar baz)))

So basically I've found that I can write the same code in the
following languages with this line ratio:

Clojure: 1
Python: 3
Java: 6

This is the reason I shelved the RPython idea. If I want to
dramatically re-define how types are handled in Clojure-py all I have
to do is re-write a single macro.

<over generalization>

"Why write a jit when you can have RPython do it for you?"

"Why write a typesystem, when you can have Clojure macros do it for you?"

</over generalization>


“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

More information about the pypy-dev mailing list