4 ms·
I like the explicit nature of Python's imports. And especially how I can choose the best way to indicate the sources of names in my code: import time t
by stevesimmons 5y ago
I like the explicit nature of Python's imports.
And especially how I can choose the best way to indicate the sources of names in my code:
import time
t = time.perf_counter()
import time, my_module
t1 = time.perf_counter()
t2 = my_module.perf_counter()
from time import perf_counter as std_counter
from my_module import perf_counter as my_counter
t1 = std_counter()
t2 = my_counter()
try:
from my_module import perf_counter
except ImportError:
# Fall back to standard implementation
from time import perf_counter
t = perf_counter()
# import time as m
import my_module as m
t = m.perf_counter()
- kazinator 5y ago> import perf_counter as my_counter Yikes; you're renaming/aliasing global identifiers! Just no.