tags:

views:

43

answers:

2

Generally speaking, should I keep one ScriptEngine for the life of the application or should I create and destroy them as needed?

+1  A: 

I would definitely try to limit the number of script engines you instantiate. It is a slow process (from my experience), so the fewer times you have to wait for it, the better.

On that note, I would be careful with only 1. I think that scripts might (just might) have the potential to interfere with eachother if you have 1. I'm not sure, but just be careful.

Stargazer712
+1  A: 

One ScriptEngine per AppDomain is fine. To isolate your scripts, make sure that each one is executed in its own ScriptScope. By reusing the ScriptEngine, IronPython won't have to recompile any imported modules, which is generally the slowest part of IronPython, especially if they are short-running scripts.

Jeff Hardy