[feat/precompile-type-caster-base] feat: move internals.h, exception_translation.h, and pybind11_fail out of line - #6135
Open
henryiii wants to merge 2 commits into
Conversation
henryiii
force-pushed
the
feat/precompile-internals
branch
from
August 7, 2026 03:27
480396b to
3fcc3bb
Compare
…t of line The internals accessor family (get_internals, ensure_internals, the local-internals key and capsules, exception translators) moves into internals-inl.h; per-module identity is unchanged because the function-local statics move with their functions into whatever binary each module links. Also adds common-inl.h (pybind11_fail) and exception_translation-inl.h. Tiny hot accessors and all templates stay in the headers. Assisted-by: ClaudeCode:claude-fable-5
henryiii
force-pushed
the
feat/precompile-internals
branch
from
August 7, 2026 03:33
3fcc3bb to
461e9eb
Compare
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.
🤖 AI text below 🤖
Description
Stacked on #6134. Fourth slice of the pre-compilation split:
detail/internals.h: the internals accessor family (get_internals,ensure_internals,get_internals_pp_manager,get_local_internals*, the capsule accessors,translate_exception,translate_local_exception,raise_err,get_python_state_dict, small utilities) moves into the existinginternals-inl.h. The per-DSO-critical function-local statics (get_local_internals_key's address-based key, the pp-manager singletons,has_seen_non_main_interpreter) move with their functions, so each extension module — linking its own copy of the static library — keeps exactly the per-module identity it has today. Linking the precompiled library into a shared core library shared by several modules shares local internals across them, which is identical to today's behavior when inline code lands in such a core library.detail/exception_translation.h→exception_translation-inl.h(apply_exception_translators,try_translate_exceptions).detail/common.h: the twopybind11_failoverloads → newcommon-inl.h. (They live in namespacepybind11, notdetail— the definitions must match.)Templates (
thread_specific_storage<T>,internals_pp_manager<T>, thewith_*callback helpers) and the tiny hot accessors (get_thread_state_unchecked,same_type) stay in the header. Verified: full test suite passes in both modes; header-only binary size unchanged.Suggested changelog entry:
📚 Documentation preview 📚: https://pybind11--6135.org.readthedocs.build/