Within one of my Django apps, I have code that looks like this within views.py:
import myLib
resultOne = myLib.myFunction('Some data')
resultTwo = myLib.myFunction('Some more data')
resultThree = myLib.myFunction('Even more data')
Whenever I visit the page, it takes a good minute to load. The reason is that myLib takes up a lot of memory and it is loading each time the page is loaded. I know that resultTwo and resultThree will execute quickly after resultOne has executed.
I want to preload myLib in Django so that it is stored in memory and so resultOne, resultTwo, and resultThree all execute quickly. How can I do this?
EDIT:
This may fall under the category of caching. The input that resultOne, resultTwo, and resultThree changes each time and they are run very often.
In Django, you can import it in
__init__.pyand access it as a variable.