Author vstinner
Recipients belopolsky, berker.peksag, bmispelon, corona10, p-ganssle, rhettinger, serhiy.storchaka, taleinat, tim.peters, vstinner
Date 2019-09-05.11:16:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567682211.48.0.383804719637.issue24416@roundup.psfhosted.org>
In-reply-to
Content
"""
./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
History
Date User Action Args
2019-09-05 11:16:51vstinnersetrecipients: + vstinner, tim.peters, rhettinger, belopolsky, taleinat, berker.peksag, serhiy.storchaka, bmispelon, p-ganssle, corona10
2019-09-05 11:16:51vstinnersetmessageid: <1567682211.48.0.383804719637.issue24416@roundup.psfhosted.org>
2019-09-05 11:16:51vstinnerlinkissue24416 messages
2019-09-05 11:16:51vstinnercreate