Pre-allocate version numbers for common builtin classes. #126547
Labels
3.14
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
We use the
tp_version
field of class objects for quite a few of our optimizations, so it gets set for almost classes.If we pre-allocate the version for common classes, like
int
,float
,tuple
, etc, then we can use the version number to speedup dispatching by class in a few cases:Examples:
BIN_OP
andCOMPARE_OP
specialization for common-ish types likeint + float
COMPARE_OP
We could add these version numbers when implementing any of the above the features, but I'm proposing adding separately to keep the size of the PR down and easier to review
Linked PRs
The text was updated successfully, but these errors were encountered: