Am 15.12.2010 21:31, schrieb Santosh Tiwari:

Hello,

I am using the method

public void exec(String s)

from the class

org.python.util.PythonInterpreter

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.

Thanks,

--
Santosh Tiwari
tiwaris@gmail.com
------------------------------------------------------------------------------ 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. http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________ Jython-users mailing list Jython-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jython-users
First invocation can/should be slow.

Jython 2.5.2b2 (Release_2_5_2beta2:7124, Sep 14 2010, 00:11:45)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_22
Type "help", "copyright", "credits" or "license" for more information.
>>> from time import clock
>>> from org.python.util import PythonInterpreter
>>> i = PythonInterpreter()
>>> start = clock() ; i.exec('print 42+0') ; print clock()-start
42
0.010172242
>>> start = clock() ; i.exec('print 42+0') ; print clock()-start
42
0.009454553
>>> start = clock() ; i.exec('print 42+0') ; print clock()-start
42
0.008971252
>>> start = clock() ; i.exec('print 42+0') ; print clock()-start
42
0.037568462
>>> start = clock() ; i.exec('print 42+0') ; print clock()-start
42
0.008597741
>>> start = clock() ; i.exec('print 42+0') ; print clock()-start
42
0.011106998
>>> start = clock() ; i.exec('print 7*7-5') ; print clock()-start
44
0.009157309
>>> start = clock() ; i.exec('print 7*7-7') ; print clock()-start
42
0.007693715
start = clock() ; i.exec('print 7*7-7') ; print clock()-start
42
0.007243937

It would be nice to see the code you are particular using,
and perhaps a sample of the python expression you tried.
Short scripts can run longer, even :-)