2 ms·
Imports only happen once. import mod is the equivalent of mod = sys.modules.get(name) if not mod: mod = sys.modules[name] = load_package(name) It’s re
by dagmx 4y ago
Imports only happen once.
import mod
is the equivalent of
mod = sys.modules.get(name)
if not mod:
mod = sys.modules[name] = load_package(name)
It’s really low cost, as long as you’re not doing it in a hot loop, it’ll be very low to no impact.