Skip to content

[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
feat/precompile-type-caster-basefrom
feat/precompile-internals
Open

[feat/precompile-type-caster-base] feat: move internals.h, exception_translation.h, and pybind11_fail out of line#6135
henryiii wants to merge 2 commits into
feat/precompile-type-caster-basefrom
feat/precompile-internals

Conversation

@henryiii

@henryiii henryiii commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

🤖 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 existing internals-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.hexception_translation-inl.h (apply_exception_translators, try_translate_exceptions).
  • detail/common.h: the two pybind11_fail overloads → new common-inl.h. (They live in namespace pybind11, not detail — the definitions must match.)

Templates (thread_specific_storage<T>, internals_pp_manager<T>, the with_* 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:

  • Placeholder.

📚 Documentation preview 📚: https://pybind11--6135.org.readthedocs.build/

henryiii and others added 2 commits August 7, 2026 08:37
…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
henryiii force-pushed the feat/precompile-internals branch from 461e9eb to 657dd93 Compare August 7, 2026 12:41
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