I want to design my new Python method such that the mainline method (here labelled “main_meth”) executes a separate calculation method (here labelled “calc_meth”. “Main_meth” will call “calc_meth” several thousand times.
The issue is that “calc_meth” requires a very large of ammount of data to be loaded from the database into a dictionary, on which the calculations are based. If “calc_meth” has to load all the data from the database into the dictionary every time it is called, it will obviously run slowly.
Is it possible to code these methods so that the dictionary in “calc_meth” is only loaded the first time it is called, not every time ? Any advice would be greatly appreciated, please.