I have a python module that I'm installing using setup.py. In one of the submodules, say, module_name.submodule, I'm doing a one-time calculation that takes a lot of time. The numbers that are produced won't change, and I will need them for various other calculations. Consequently, every time I load the python module in a script, it takes a long time. Is there any way to calculate and save these numbers only when the python package is being installed?
setup.py looks like this:
from setuptools import setup, find_packages
import module_name
setup(
      name = 'module_name',
      ...
      packages = find_packages()
     )
module_name/submodule.py looks like this:
def func1():
    ...
CONST_VARS = []
... calculate here (takes a long time)...
What is the best way to handle this situation? I don't want to write the constant vars into the script by hand (or to a file or something).
 
    