This is a priority. As mentioned earlier, the newcompiler project - which fully supports Python 2.5 from a compilation perspective - currently depends on having CPython bytecode, specifically what's emitted in *.pyc files. Tobias wrote a very clever piece of code - and short, it's just over a page! - that makes it much easier to use via import filters; you can do this:

import pycimport

and import any CPython 2.5 modules you like into Jython. (Look in newcompiler/PyASM.) Most importantly, this filter, like any other import filter, supports any module dependencies. The logic is that it will use a pyc if it's there, and compile via the newcompiler; otherwise, the module import goes through the standard ("oldcompiler") in Jython.

This let's you run generator expressions, decorators, etc., to whatever degree you like, as long as you satisfy two caveats:
  1. Precompiled your Python code into *.pyc files, as typically is done by a script (as supported by distutils or setuptools)
  2. No dependence on some missing functionality in Jython (or at least since we last merged with the trunk), such as builtins, etc.
It's obviously much harder to satisfy caveat #2. I've been experimenting with concurrency features, and it's annoying that Jython trunk threading.Lock does not have __enter__ and __exit__ defined, even though I can use the with statement; that is

with lock:
     # process away

compiles fine. It just will complain quickly about missing methods. And so on and so forth. Those working on Django on Jython, IPython on Jython, etc., know the feeling.

What's the timeline? Well Tobias and I hope to have something more usable by PyCon in March - we put in a proposal "A New Compiler for Jython"; and of course there's a lot of work out there to plug in the gaps in Jython modules and builtins. I'm sure we have all noted the increased pace on this work here on this list.

Finally on #jython, we agreed to have a AST sprint on Saturday, December 8, to take the generational grammar in Antlr work that Damien  did, based on some modifications I made to an existing Python 2.3 recognizer grammar by Parr & Craymer. What we are planning to do is divide up the rules and reproduce in Antlr what CPython _ast currently does. My feeling is that this is best done by an additional tree grammar step, especially since CPython does that too. I'll be posting more about the sprint and the prep homework for participants later this week. Among other things, this should be a great opportunity to learn Antlr and do something interesting with it.

If we have the AST, we can avoid the piggybacking on CPython for newcompiler, so that definitely will get us a lot closer.

- Jim

On Nov 27, 2007 8:42 PM, Mehendran T <> wrote:

It is probably the right time to ask, I think.

May I know about when the new compiler will be integrated in jython?

The question comes because Jython lacks for features like Generator
expressions, Function/method decorators according to the link


SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
Jython-dev mailing list

Jim Baker