It works. :)
Now Jython's "exec" method call is no more the time consuming part of my
application.
Thanks.
On Thu, Dec 16, 2010 at 11:08 AM, Jeff Emanuel <jemanuel@...> wrote:
>
> interp.set("x",1)
> interp.exec(compiledCode)
>
> Santosh Tiwari wrote:
>
>>
>> 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 <jemanuel@... <mailto:
>> jemanuel@...>> 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)
>> method.
>>
>>
>> Santosh Tiwari wrote:
>>
>>
>> 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@... <mailto:tiwaris@...>
>> <mailto:tiwaris@... <mailto:tiwaris@...>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> 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@...
>> <mailto:Jython-users@...>
>>
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>
>>
>>
>>
>> --
>> Santosh Tiwari
>> tiwaris@... <mailto:tiwaris@...>
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> 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@...
>> https://lists.sourceforge.net/lists/listinfo/jython-users
>>
>>
>
--
Santosh Tiwari
tiwaris@...
|