Prepare lower-overhead native union rollback integration - #34
Draft
acecchini wants to merge 8 commits into
Draft
Conversation
added 4 commits
September 8, 2026 17:05
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.
A rejected composite union alternative can leave dimension bindings behind and reject a valid later argument. This PR prepares the bearshape adapter for an upstream transaction boundary: the proposed
__beartype_state__()hook returns the active memo, whose existing snapshot/restore methods protect complete alternatives, failures and diagnostics.The optimized beartype proposal is local at
76e27706fb137c6a676ee7b79a66d8b3092b52ad, based ona2729e0e358bf963ee6f177e300ae08a622d05d6. It compiles the checking function once, locates state once per expression, uses compact rollback records and avoids redundant root snapshots and stateless-path setup. The final review also fixed state retention and stale parent registration after copying an execution context. It has not been submitted or published. The dependency floor and lock remain on rc0; 20 of the 22 explicit integration tests still fail on rc0 and are not hidden behind skips or xfails. Normal hosted CI therefore proves baseline compatibility, not the unpublished integration.Matched measurements include the independent frame filter in PR #35 and separate its improvement from upstream overhead. Added strict-check cost fell from 12.009/12.504 to 5.206/3.209 microseconds on Python 3.10/3.14 (57%/74% lower). Correct fallback-union calls fell from 51.499/52.596 to 32.908/25.489 microseconds. Nested ordinary forward references still add about 0.74/0.42 microseconds over rc0; that tradeoff remains explicit. The maintained benchmark records wrong baselines as incorrect and preserves repeat samples. All measurements include the final lifetime correction.
Validation: the combined, normally installed artifacts passed 1,125 archive-extracted runtime/checker/integration tests per endpoint, including all four static engines. Upstream passed 434/447 unit tests, including 22 protocol tests with 600 independent-reference cases, and pyright on both targets. All 22 protocol tests also passed against installed wheels outside the upstream checkout. Minimal environments, distribution integrity, hooks and docs passed. Five existing CPU skip records remain; no new CUDA evidence is claimed.
The focused ExecPlan and
tools/upstream/README.mdrecord reproduction, artifact identities, measurements and availability. Keep this draft while the upstream contract and supported release are pending. No feature merge, package publication, ownership transfer or upstream communication was performed.