问题
I apologize in advance if my question is badly formulated, for I don't know if what I need makes any sense.
I'm currently working on a c# project where I need to run several time the same python script from inside the program, but with different arguments each time. For this, I'm not using IronPython, but the ProcessStartInfo class, for I understood that IronPython has some problem with certain packages I use. But this can change.
My problem is that although the python script is small and fast, it needs to import first a lot of packages, and this takes a lot of time. And therefore, my code is very slow, while 90% of the time is used to import python packages. I can't work around the problem by running this python script a single time with many arguments.
So is there a way to "open a permanent python console" from c#, where I could import everything once, then run the small script with my first argument, get the result back in c#, then run the script a second time etc .... ? Or any other way to optimize this ?Thanks for your help,
Astrosias.
来源:https://stackoverflow.com/questions/62213494/optimizing-python-scripts-running-time-from-c-sharp