[issue42202] Optimize function annotation

Jakub Stasiak report at bugs.python.org
Tue Nov 17 11:47:32 EST 2020


Jakub Stasiak <jakub+python.org at stasiak.at> added the comment:

Yurii, I don't believe that benchmark measures what you need to measure (once imported module is kept imported forever until unloaded, so successive imports are no-ops).

See how the side effects of importing bbb only happen once: 

% cat bbb.py 
import time
time.sleep(1)
with open('bbb.log', 'a') as f:
    written = f.write('hello\n')
    assert written == 6

% time python -m timeit "import bbb"
1 loop, best of 5: 515 nsec per loop
python -m timeit "import bbb"  0.03s user 0.01s system 4% cpu 1.050 total

% cat bbb.log 
hello

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42202>
_______________________________________


More information about the Python-bugs-list mailing list