This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients larry, scoder, serhiy.storchaka, vstinner, xtreak
Date 2019-01-11.15:12:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547219527.5.0.219646816475.issue35582@roundup.psfhosted.org>
In-reply-to
Content
I converted msg333446 into attached bench.py using perf. Results on my laptop:

vstinner@apu$ ./python -m perf compare_to ref.json inlined.json --table -G
+-------------------------+---------+------------------------------+
| Benchmark               | ref     | inlined                      |
+=========================+=========+==============================+
| format('abc')           | 74.4 ns | 43.7 ns: 1.70x faster (-41%) |
+-------------------------+---------+------------------------------+
| 'abc'.replace('x', 'y') | 93.0 ns | 57.5 ns: 1.62x faster (-38%) |
+-------------------------+---------+------------------------------+
| (1, 2, 3).index(2)      | 92.5 ns | 59.2 ns: 1.56x faster (-36%) |
+-------------------------+---------+------------------------------+
| a.index(2)              | 93.6 ns | 59.9 ns: 1.56x faster (-36%) |
+-------------------------+---------+------------------------------+
| 'abc'.ljust(5)          | 124 ns  | 86.0 ns: 1.44x faster (-30%) |
+-------------------------+---------+------------------------------+
| math.pow(0.5, 2.0)      | 121 ns  | 88.1 ns: 1.37x faster (-27%) |
+-------------------------+---------+------------------------------+

The speedup on my laptop is between 30.7 and 38.0 ns per function call, on these specific functions.

1.7x faster on format() is very welcome, well done Serhiy!

Note: You need the just released perf 1.6.0 version to run this benchmark ;-)
History
Date User Action Args
2019-01-11 15:12:09vstinnersetrecipients: + vstinner, scoder, larry, serhiy.storchaka, xtreak
2019-01-11 15:12:07vstinnersetmessageid: <1547219527.5.0.219646816475.issue35582@roundup.psfhosted.org>
2019-01-11 15:12:07vstinnerlinkissue35582 messages
2019-01-11 15:12:07vstinnercreate