Is it possible to hand over a library import in Python to a subroutiune?
I got the problem, that the import of a certain matplotlib version took very long. To see where it comes from I did for each library import the following:
timer = time.time()
import theLibToImport as tlti
print("import theLibToImport took %.3f sec" % (time.time()-timer))
I would prefer something like this
tldi = myImport("theLibToImport")
def myImport(theLib: str):
timer = time.time()
import theLib as shortName # some Python woodoo to transfer string to module
print("import %s took %.3f sec" % (theLib,time.time()-timer))
return shortName
The library should be globally available in the py file. Is this possible in a comparable way?