Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm curious, can PyPy JIT-compile Python bytecode by itself, or does it require the source to be in Python? Because it would be really cool if you could target the Python "platform" and get a free JIT as well.

Edit: Nevermind, just read the project readme[1] where they explicitly mention targeting PyPy as a goal.

[1] https://github.com/halgari/clojure-py



> I'm curious, can PyPy JIT-compile Python bytecode by itself, or does it require the source to be in Python?

Considering you can run bytecode-only Python, it would be weird if Pypy's JIT only worked from source.

Beyond that, they're apparently implementing Clojure on top of (in) Python, so they won't get the JIT for free (the interpreter code will be JITed, but the Clojure code won't be unless their runtime compiles to Python bytecode which does not seem to be the case). They'd get it for free if they implemented a Clojure in RPython as well, but would leave the Python ecosystem behind.


From the article

> clojure-py is an implementation of the Clojure language in Python, compiling Clojure code to bytecode for Python’s virtual machine

Which means both the compiler (mostly an AST walk from the look of clojure/lang/compiler.py) and the Python bytecode it produces should benefit from PyPy's JIT.


This is very correct. We compile Clojure code to Python bytecode. Clojure functions become python functions, clojure deftypes are Python classes, Clojure namespaces are Python modules. And yes, it runs perfectly well on PyPy. Actually it sometimes runs a bit better. CPython segfaults with bad bytecode sequences (unbalanced stacks). PyPy actually throws an error so you can fix the code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: