I have the problem, that in some cases the Execute
method for an ScriptSource
takes a long time. This is problematic, because i use this method very often for the same ScriptSources. Now i tried to compile ScriptSource
and save the result object. Then i use the Execute
method on the compiled code, but this seems as slow as Execute
on the ScriptSource
directly.
I`ve made a simple example:
private static Dictionary<string, CompiledCode> compiledCode = new Dictionary<string, CompiledCode>();
// Method
public void LoadScript(string Name)
{
if (compiledCode.ContainsKey(Name))
{
compiledCode[Name].Execute(scriptScope);
}
else
{
ScriptSource source = IronPythonScriptHost.Singleton.GetScriptSource(Name);
CompiledCode code = source.Compile();
compiledCode.Add(Name, code);
code.Execute(scriptScope); // Use an instanced ScriptScope
}
}
Why is the compiled code not faster?
Or did i do somthing wrong in general?
Thank you