FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-145497: Fix _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES by vstinner · Pull Request #151152 · python/cpython · GitHub

Repository navigation

gh-145497: Fix _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES - #151152

Closed
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:static_exceptions
Closed

vstinner wants to merge 1 commit into
python:mainfrom
vstinner:static_exceptions

Conversation

vstinner commented Jun 9, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

The _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES macro is no longer a hardcoded number to reduce the maintenance burden.

  • Add _Py_NUM_STATIC_EXCEPTIONS: size of the static_exceptions array.
  • Add _Py_FOREACH_STATIC_EXTRA_TYPE() to count the number of extra types.

The _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES macro is no longer a
hardcoded number to reduce the maintenance burden.

* Add _Py_NUM_STATIC_EXCEPTIONS: size of the static_exceptions array.
* Add _Py_FOREACH_STATIC_EXTRA_TYPE() to count the number of extra
  types.

Co-authored-by: Donghee Na <donghee.na@python.org>
update one of these numbers.
*/
#define _Py_NUM_MANAGED_PREINITIALIZED_TYPES 120
#define _Py_NUM_STATIC_EXCEPTIONS 69

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Now you mange the number of _Py_NUM_STATIC_EXCEPTIONS manually, I beleive that this is not what we wanted

If you add a new static type to the standard library, you may have to
update one of these numbers.
*/
#define _Py_NUM_MANAGED_PREINITIALIZED_TYPES 120

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Still _Py_NUM_MANAGED_PREINITIALIZED_TYPES is manged by hand.

corona10 commented Jun 9, 2026

Copy link
Copy Markdown
Member

My original intention of this issue is that people don't need to care about the actual number of types they need to know.

vstinner commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@corona10:

Still _Py_NUM_MANAGED_PREINITIALIZED_TYPES is manged by hand.

If you had an item to static_types, you get a compiler warning. You get a hint a build time that something is wrong. It should help to detect when _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES is outdated.

corona10 commented Jun 9, 2026

Copy link
Copy Markdown
Member

If you had an item to static_types, you get a compiler warning. You get a hint a build time that something is wrong. It should help to detect when _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES is outdated.

Yeah I agree that point, the only problem might be coverage of the solution that we want to cover :)

Copy link
Copy Markdown
Member Author

This approach requires to maintain a hardcoded list of "static extra type" which again can get outdated if a new static type is added. I wrote a different approach which actually counts static types at Python startup to make sure that macros are up to date.

See my new PR gh-157582. I close this one.

vstinner closed this Sep 15, 2026
vstinner deleted the static_exceptions branch September 15, 2026 18:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL