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 collinwinter
Recipients collinwinter, jyasskin
Date 2009-02-06.23:48:46
SpamBayes Score 7.270884e-11
Marked as misclassified No
Message-id <1233964189.56.0.504237250684.issue5176@psf.upfronthosting.co.za>
In-reply-to
Content
This patch speeds up the string formatting % operator by avoiding the
unnecessary indirection in PyNumber_Remainder(). This particularly
benefits templating systems that do a lot of string formatting via %.

Performance tested with gcc 4.3.1 x86_64 on Linux 2.6.18:

2to3:
Min: 22.443 -> 22.306: 0.61% faster
Avg: 22.465 -> 22.324: 0.63% faster

Django:
Min: 0.598 -> 0.591: 1.24% faster
Avg: 0.601 -> 0.595: 1.03% faster

Spitfire [1]:
Min: 0.752 -> 0.717: 4.91% faster
Avg: 0.754 -> 0.719: 4.83% faster

The Django test renders a 150x150 cell table 100 times. The Spitfire
test renders a 1000x1000 cell table 100 times. The 2to3 test translates
all of 2to3 with `-f all` five times. There is no significant impact on
PyBench. Less important code like the pure-Python pickle implementation
also shows an improvement:

Pickling:
Min: 6.680 -> 6.535: 2.22% faster
Avg: 6.740 -> 6.576: 2.50% faster

This is pickling a list of 40000 dicts 100 times. This does not impact
unpickling.

About the patch:
I tested various combinations of PyString_Check and PyString_CheckExact
and what you see in the patch demonstrated the best performance across
all benchmarks. I also tested changing the definition of PyString_Check
to include a short-circuit on PyString_CheckExact, but that did not
provide a consistent benefit. 

[1] - http://code.google.com/p/spitfire/
History
Date User Action Args
2009-02-06 23:49:49collinwintersetrecipients: + collinwinter, jyasskin
2009-02-06 23:49:49collinwintersetmessageid: <1233964189.56.0.504237250684.issue5176@psf.upfronthosting.co.za>
2009-02-06 23:48:49collinwinterlinkissue5176 messages
2009-02-06 23:48:47collinwintercreate