0

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?

8
  • 1
    No, that's not possible. Commented 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 output Commented 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. Commented 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 caller Commented Oct 11, 2019 at 11:07
  • 1
    This may point into an interesting direction for you: stackoverflow.com/questions/471191/why-compile-python-code Commented Oct 11, 2019 at 11:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.