STINNER Victor <vstin...@python.org> added the comment:
""" ./python.exe -m timeit -r11 -s 'import datetime' -s 'a = datetime.datetime.now().isocalendar()' 50000000 loops, best of 11: 8.72 nsec per loop Let me know if the benchmark code is not appropriate """ Hum wait, this benchmark measures the performance of the pass opcode... That's why it's so fast :-) -s 'a = datetime.datetime.now().isocalendar()' is run exactly once for the whole benchmark, not at each benchmark iteration... I suggest you this microbenchmark instead: ./python.exe -m pyperf timeit -s 'import datetime; dt = datetime.datetime.now()' 'dt.isocalendar()' For example, on my Fedora 30 with Python 3.7.4, I get: Mean +- std dev: 108 ns +- 4 ns ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue24416> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com