GH-113710: Backedge counter improvements.#115166
Merged
markshannon merged 2 commits intopython:mainfrom Feb 13, 2024
Merged
Conversation
Closed
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Member
|
@markshannon FWIW, even after this PR I find it hard to follow how the Tier 2 optimization backoff counters are managed. The bit fiddling is exceedingly complicated. Maybe we should have some macros for these, like we do for specialization counters. |
till-varoquaux
added a commit
to till-varoquaux/cpython
that referenced
this pull request
Apr 20, 2026
Consolidate duplicated logic and boilerplate across Annotated, GenericAlias, and Union types by introducing a shared internal header Include/internal/pycore_typing.h. This refactoring introduces subtle semantic improvements and fixes: - Implement `_Py_typing_init_parameters` to provide consistent, thread-safe lazy initialization of `__parameters__` using critical sections (fixing a lack of synchronization in GenericAlias). - Implement `_Py_typing_set_orig_class` to consistently set `__orig_class__` while ignoring all exceptions, matching `typing.py`'s behavior and addressing pythongh-115166. - Update `_Py_is_unpacked_typevartuple` to use a strict identity check against `Py_True` (instead of `PyObject_IsTrue`) to avoid issues with stringified annotations (cf. pythongh-137706). Other changes: - Introduce Include/internal/pycore_typing.h for shared typing utilities. - Consolidate parameter substitution and caching helpers. - Extract attribute proxying into `_Py_typing_proxy_getattro` and `setattro`. - Register `_PyAnnotated_Type` as a static type in `Objects/object.c`.
till-varoquaux
added a commit
to till-varoquaux/cpython
that referenced
this pull request
Apr 20, 2026
Consolidate duplicated logic and boilerplate across Annotated, GenericAlias, and Union types by introducing a shared internal header Include/internal/pycore_typing.h. This refactoring introduces subtle semantic improvements and fixes: - Implement `_Py_typing_init_parameters` to provide consistent, thread-safe lazy initialization of `__parameters__` using critical sections (fixing a lack of synchronization in GenericAlias). - Implement `_Py_typing_set_orig_class` to consistently set `__orig_class__` while ignoring all exceptions, matching `typing.py`'s behavior and addressing pythongh-115166. - Update `_Py_is_unpacked_typevartuple` to use a strict identity check against `Py_True` (instead of `PyObject_IsTrue`) to avoid issues with stringified annotations (cf. pythongh-137706). Other changes: - Introduce Include/internal/pycore_typing.h for shared typing utilities. - Consolidate parameter substitution and caching helpers. - Extract attribute proxying into `_Py_typing_proxy_getattro` and `setattro`. - Register `_PyAnnotated_Type` as a static type in `Objects/object.c`.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PR clarifies the handling of counters and triggering of the optimizer in
JUMP_BACKWARD.This PR: