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.

classification
Title: Clean up the C3 MRO algorithm implementation.
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pitrou, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-12-20 15:40 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4942 merged serhiy.storchaka, 2017-12-20 15:42
Messages (3)
msg308739 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-20 15:40
The C3 MRO algorithm implementation uses lists and converts input tuples to lists. This is redundant, because these lists are not mutated. The proposed PR makes the implementation using tuples and gets rid of unneeded conversions.
msg308751 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-20 17:18
This has also a performance effect.

$ ./python -m perf timeit -s "class A: pass" -s "class B: pass" --duplicate 1000  "class C(A, B): pass"

Before: Mean +- std dev: 9.41 us +- 0.28 us
After:  Mean +- std dev: 8.94 us +- 0.28 us
msg308752 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-12-20 17:21
New changeset 6b91a5972107ec8dd5334f4f2005626baa2b8847 by Serhiy Storchaka in branch 'master':
bpo-32385: Clean up the C3 MRO algorithm implementation. (#4942)
https://github.com/python/cpython/commit/6b91a5972107ec8dd5334f4f2005626baa2b8847
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76566
2017-12-20 17:26:59serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-12-20 17:21:04serhiy.storchakasetmessages: + msg308752
2017-12-20 17:18:17serhiy.storchakasetmessages: + msg308751
2017-12-20 15:42:35serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request4834
2017-12-20 15:40:56serhiy.storchakacreate