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

Adjust _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES value automatically · Issue #145497 · python/cpython · GitHub

Repository navigation

Adjust _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES value automatically #145497

Open

Description

When a new built-in type is introduced, _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES needs to be updated accordingly.
(e.g., 3e2f5c1, #145496 (comment))

This is quite painful, and sometimes we even forget to adjust it. To prevent this kind of issue, we may need a way to update it automatically, or add a test that verifies it is set correctly.

cc @markshannon @Fidget-Spinner @vstinner

Linked PRs

Activity

  1. vstinner commented on Mar 4, 2026

    Member

    How do you want to compute _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES value?

    The static_types array in Objects/object.c only has 118 entries (where _PyUOpExecutor_Type is only available if _Py_TIER2 macro is defined), whereas _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES is equal to 201 (it should be 202, PR gh-145496 fix it). So I don't see the direct relationship between static_types and _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES.

  2. corona10 commented on Mar 4, 2026

    MemberAuthor

    How do you want to compute _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES value?

    I don't think about it concretely, but I believe that we need to find a better way.

  3. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    type-featureA feature request or enhancement
    on Mar 5, 2026
  4. self-assigned this
    on Mar 5, 2026
  5. ZeroIntensity commented on Apr 29, 2026

    Member

    Another example of this causing issues: #149121. At the very least, it would be nice to have a test that verified the number, so we don't run into weird issues on the main branch when we forget to fix it.

    So I don't see the direct relationship between static_types and _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES.

    Hm, what is _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES if not the length of static_types? Where do the other ~80 entries come from?

  6. JelleZijlstra commented on Apr 29, 2026

    Member

    Seems the rest are mostly exception classes and a few others that aren't in static_types itself.

    Here's a list from printing every type that gets added:

    static.txt

  7. encukou commented on Apr 29, 2026

    Member

    See also #149121.

  8. added a commit that references this issue on May 1, 2026
  9. StanFromIreland commented on May 2, 2026

    Member

    Triage: with #149139 merged, can this be closed?

  10. StanFromIreland commented on May 2, 2026

    Member

    Ooops wrong button.

  11. added
    pendingThe issue will be closed if no feedback is provided
    on May 2, 2026
  12. corona10 commented on May 2, 2026

    MemberAuthor

    Yes we can close! Thank you @encukou

  13. encukou commented on May 4, 2026

    Member

    Sadly, that PR is just a workaround. It would still be nice to adjust this automatically.

  14. reopened this on May 4, 2026
  15. removed
    pendingThe issue will be closed if no feedback is provided
    on May 4, 2026
  16. added 2 commits that reference this issue on Sep 15, 2026
  17. vstinner commented on Sep 15, 2026

    Member

    Please see my new PR gh-157582 which actually counts static types at Python startup (in debug mode) to make sure that macros are still up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL