Author fmartins
Recipients fmartins, zyasoft
Date 2015-05-12.10:38:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1431427084197.69802.8906@webmail5>
In-reply-to <>
I don't see an option to reply in the bug tracker...

The 1st solution seems indeed convoluted and I don't think it would work in my use case since no $py.class file is generated when the python script is compile(). Plus, if it is slow, probably not very useful to my use case either since the scripts are usually small (around 50 LOC avg).

But I would like to propose another alternative. You mention the option of "preemptively storing bytecode". In general it would be bad, but what about having an option in jython allowing the programmer to request the code to be stored. In this case marshal.dump would check for the cached code and save it instead of bailing out. This approach would keep compatibility with Python, I think.

On 12 May 2015, Jim Baker <> wrote:
> Jim Baker added the comment:
> Throwing an exception is certainly easiest... but I will attempt to sketch out a solution.
> Java bytecode cannot be accessed once loaded, and preemptively storing bytecode just-in-case is too much overhead for functionality that is rarely used. Assuming the source jar (or class file) is still available, we could use the inspect module to find the $py.class file. Then we could find the specific code object in the PyFunctionTable by introspecting for the index. Then we could ASM to write out the specific code object. Note that reloading a single code object via a ClassLoader will be quite inefficient, which is a big reason we have the PyFunctionTable approach today.
> We probably don't want to do this solution.
> Python bytecode is a long term scenario for Jython for code objects that are not hot. Such code objects can be readily dumped and loaded, and there's currently support in marshal for loading them to support pycimport. One we fully implement Python bytecode for this, we will have Python bytecode for every object, and only for hot code we will have - in addition - equivalent, but optimized Java bytecode. But this is not hapenning any time soon.
> So throwing an exception is the correct solution for now.
> ----------
> nosy: +zyasoft
> _______________________________________
> Jython tracker <<>>
> <<>>
> _______________________________________
File name Uploaded
unnamed fmartins, 2015-05-12.10:38:08
Date User Action Args
2015-05-12 10:38:09fmartinssetrecipients: + fmartins, zyasoft
2015-05-12 10:38:09fmartinslinkissue2354 messages
2015-05-12 10:38:09fmartinscreate