I have a python script that imports modules and that modules are importing top level modules this process takes long period of time, over 5 seconds. Is there a way in python to import modules once and reuse it for several times? Is it possible to avoid re importing python modules when you exit your script and rerun your script again?
-
1No, that's not possible.Aran-Fey– Aran-Fey2019-10-11 10:57:14 +00:00Commented Oct 11, 2019 at 10:57
-
@Aran-Fey is a way to run a python script like service and this python script gets some argument and returns outputstudent– student2019-10-11 11:03:30 +00:00Commented Oct 11, 2019 at 11:03
-
You could create a loop that does what you want and maybe require a keypress each time. Really depends what your script is doing.Frederik Højlund– Frederik Højlund2019-10-11 11:05:06 +00:00Commented Oct 11, 2019 at 11:05
-
@FrederikHøjlund how i can run my python script that takes a an argument as http POST and returns it to callerstudent– student2019-10-11 11:07:11 +00:00Commented Oct 11, 2019 at 11:07
-
1This may point into an interesting direction for you: stackoverflow.com/questions/471191/why-compile-python-codeJens– Jens2019-10-11 11:21:21 +00:00Commented Oct 11, 2019 at 11:21
|
Show 3 more comments