Skip to content

Prepare lower-overhead native union rollback integration - #34

Draft
acecchini wants to merge 8 commits into
mainfrom
codex/union-transactions
Draft

Prepare lower-overhead native union rollback integration#34
acecchini wants to merge 8 commits into
mainfrom
codex/union-transactions

Conversation

@acecchini

@acecchini acecchini commented Sep 8, 2026

Copy link
Copy Markdown
Owner

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 on a2729e0e358bf963ee6f177e300ae08a622d05d6. 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.md record 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.

@acecchini acecchini changed the title Fix state rollback across native union alternatives Prepare native union rollback integration Sep 8, 2026
@acecchini acecchini changed the title Prepare native union rollback integration Prepare lower-overhead native union rollback integration Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant