I have a large python script that I broke up into a main file and 5 smaller python files with functions that are called from the main file. However, I find that I need to import the same python packages/ libraries (e.g json, flask, csv, ...etc) in many of the smaller files. I.e many of the files start with the same “import json, csv,...etc’ command. My question is does importing the same package across the python files slow down performance in a material way? Or would python load the library the first time it encounters it in memory and then just use it for the other files if it is called ?
Asked
Active
Viewed 41 times
1
-
2The second one. No performance hit, just a lookup into sys.modules. – Mad Physicist Jan 20 '19 at 06:36