0
我試圖延長使用IronPython的我的WebApp之一,遺憾的是下面的代碼運行得慢:存儲昂貴的對象,以便在ASP.NET MVC中重用?
var engine = Python.CreateEngine();
SourceCodeKind st = SourceCodeKind.Statements;
string source = "print 'Hello World'";
var script = engine.CreateScriptSourceFromString(source, st);
var scope = engine.CreateScope();
script.Execute(scope);
我假設了Python引擎的創建採取的大部分時間,因爲即使像Python這樣的解釋性語言應該運行得相對較快。
因此,假設我的假設是正確的;我可以在任何地方存儲Python引擎以節省每次創建它的費用嗎?還是有更好的方法來做到這一點?
安東尼