Great suggestion. Thanks.

I tried what you said. I am encountering the following problem.

Here is my scenario.

I am using the same jython interpreter object to evaluate different set of user-provided equations (each set is about 50 lines of python code).

User provides the input values (for variables) in a table, and I generate the python source code as follows.

Suppose 'x' is input and 'y' is output.

User-provided equation is 'y = x'

and user set an initial value for variable 'x' to be 1.0

I pass the following equation to jython.

x = 1.0;
y = x;

Ofcourse, the first line will change as the input value 'x' changes. What should I do to set the appropriate values for the input variables, so that my equations get evaluated correctly.

Thanks again for the suggestion.

On Wed, Dec 15, 2010 at 5:10 PM, Jeff Emanuel <> wrote:

If you pass the same source string multiple times
you can amortize the cost of compiling by compiling
the source once and passing it to the exec(PyObject)

Santosh Tiwari wrote:


I am using the method

public void exec(String s)

from the class


to evaluate user provided expressions in my java application.

After having profiled my application, I figured this method takes a noticeable amount of time to execute.

What recommendations do you have to make the execution faster?

I basically pass the user provided source code to the jython engine, and then fetch the relevant key-value pairs.

Any pointers about using the jython engine more efficiently would be helpful.


Santosh Tiwari <>


Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.

Jython-users mailing list

Santosh Tiwari