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 scoder
Recipients methane, pitrou, rhettinger, scoder, serhiy.storchaka, vstinner
Date 2017-09-05.18:10:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1504635032.04.0.877225205051.issue31336@psf.upfronthosting.co.za>
In-reply-to
Content
I updated the pull request with a split version of _PyType_Lookup() that bypasses the method cache during slot updates. I also ran the benchmarks with PGO enabled now to get realistic results. The overall gain is around 15%.

Original:
$ ./python -m timeit 'class Test: pass'
20000 loops, best of 5: 7.29 usec per loop

Patched:
$ ./python -m timeit 'class Test: pass'
50000 loops, best of 5: 6.15 usec per loop

Patched with non-trivial bases:
$ ./python -m timeit 'class Test(object): pass'
50000 loops, best of 5: 6.05 usec per loop
$ ./python -m timeit 'class Test(type): pass'
50000 loops, best of 5: 6.08 usec per loop
$ ./python -m timeit 'class Test(int): pass'
50000 loops, best of 5: 9.08 usec per loop

I do not consider the optimisations a code degredation.

There is one semantic change: the new function _PyType_LookupUncached() returns on the first error and might set an exception. I considered that better behaviour than the old function, but it means that if one base class name lookup fails and the next one previously succeeded, it will no longer succeed now. I don't have a strong feeling about this and would change it back if compatibility is considered more valuable. It generally feels wrong to have errors pass silently here, however unlikely they may be in practice.
History
Date User Action Args
2017-09-05 18:10:32scodersetrecipients: + scoder, rhettinger, pitrou, vstinner, methane, serhiy.storchaka
2017-09-05 18:10:32scodersetmessageid: <1504635032.04.0.877225205051.issue31336@psf.upfronthosting.co.za>
2017-09-05 18:10:32scoderlinkissue31336 messages
2017-09-05 18:10:31scodercreate