how is this solution I am using now:
I have a 1MB .dbf file in the same directory of all my .py modules. In main.py I have
import tools
In tool.py code is :
the_list_that_never_changes = loadDbf(file).variables['CNTYIDFP'].
So the_list_that_never_changes is only loaded once and is always in memory ready to be used…correct?
Static files are stored apart from application files. If you need to load
data.pklfrommain.py, then don’t mark it as a static file and it will be accessible bymain.pylike any other application file.Reference: Application Configuration’s Handlers For Static Files.
Alternative: Why not define the information stored in
data.pklas a global variable in your Python source? Then you don’t have to go through the trouble of reading a file and deserializing its pickled contents, and it will be a bit faster too. This will also make it easy to take advantage of app caching – your data will be loaded once, and then cached for use by subsequent requests.