Collin Winter <coll...@gmail.com> added the comment: Updated the patch to use only PyString_CheckExact(); added a test for the behaviour of string subclasses wrt the % operator.
There's a very slight performance hit when using % with numbers, but it's so small as to be statistically insignificant. If it turns out to be relevant in the future, it's easy enough to add a special case for ints/longs. For some reason, using PyString_CheckExact instead of PyString_CheckExact || PyString_Check actually results in slower code (still an improvement, but not as much). The weird thing is that none of the benchmarks I'm running use % on string subclasses at any point. I talked about it with some of the gcc guys, but they didn't have any immediate leads. I'm going to send them the .o files in case gcc is missing some optimization. New benchmark numbers: Spitfire: Min: 0.687 -> 0.668: 2.96% faster Avg: 0.689 -> 0.669: 2.96% faster 2to3: Min: 20.376 -> 20.187: 0.94% faster Avg: 20.396 -> 20.225: 0.84% faster Django: Min: 0.560 -> 0.549: 1.94% faster Avg: 0.562 -> 0.552: 1.93% faster SlowPickle: Min: 0.920 -> 0.905: 1.62% faster Avg: 0.926 -> 0.913: 1.38% faster Added file: http://bugs.python.org/file13077/faster_modulo.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5176> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com