Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-allocate version numbers for common builtin classes. #126547

Closed
markshannon opened this issue Nov 7, 2024 · 0 comments
Closed

Pre-allocate version numbers for common builtin classes. #126547

markshannon opened this issue Nov 7, 2024 · 0 comments
Labels
3.14 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@markshannon
Copy link
Member

markshannon commented Nov 7, 2024

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 and COMPARE_OP specialization for common-ish types like int + float
  • Specialization of other ops like COMPARE_OP
  • Reducing the overhead of traversing objects in the garbage collector
  • Possible performance improvements to marshal and pickle.

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

@markshannon markshannon added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.14 new features, bugs and security fixes labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

1 participant