[pypy-dev] replacing/modifying __import__

Timothy Baldridge tbaldridge at gmail.com
Mon Feb 13 15:18:13 CET 2012

I'm in the process of writing a Clojure->Python bytecode compiler
(http://github.com/halgari/clojure-py). The project is going quite
well and runs great on PyPy and CPython. However there is one feature
I'm not quite sure how to implement in PyPy. What I would like, is to
extend 'import' so that it can handle .clj files:

import clojure.core # where there is a file called clojure/core.clj

Now in CPython I can simply ovewrite __builtins__.__import__ with a
new function that adds additional functionality to __import__.
However, in PyPy we can't change __builtins__. So is there a better
option? The interop between clojure and python is so good already,
that I'd hate to make users run:

import clojure

Any ideas?



“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