Skip to content

[feat/precompile-type-caster-base] feat: move internals.h, exception_translation.h, and pybind11_fail out of line - #6135

Merged
henryiii merged 2 commits into
feat/precompile-type-caster-basefrom
feat/precompile-internals
Oct 3, 2026
Merged

henryiii merged 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.h → exception_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
henryiii force-pushed the feat/precompile-internals branch from 480396b to 3fcc3bb Compare August 7, 2026 03:27
@henryiii
henryiii force-pushed the feat/precompile-internals branch 2 times, most recently from 461e9eb to 657dd93 Compare August 7, 2026 12:41
@henryiii
henryiii force-pushed the feat/precompile-internals branch from c7a72cb to 18600f3 Compare August 9, 2026 02:51
@henryiii
henryiii force-pushed the feat/precompile-internals branch from 18600f3 to e0f3ecd Compare August 11, 2026 02:59
@henryiii
henryiii force-pushed the feat/precompile-internals branch from e0f3ecd to 533af13 Compare August 11, 2026 22:13
@henryiii
henryiii force-pushed the feat/precompile-internals branch from 533af13 to 643238c Compare August 12, 2026 02:18
@henryiii
henryiii force-pushed the feat/precompile-internals branch from 643238c to 06cb9f7 Compare August 15, 2026 03:45
@henryiii
henryiii force-pushed the feat/precompile-internals branch from 06cb9f7 to dc0482e Compare August 17, 2026 04:50
…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
Assisted-by: ClaudeCode:claude-fable-5
@henryiii
henryiii force-pushed the feat/precompile-internals branch from dc0482e to 4aead5c Compare September 27, 2026 02:19
@henryiii
henryiii merged commit ba6d80e into master Oct 3, 2026
101 of 171 checks passed
@henryiii
henryiii deleted the feat/precompile-internals branch October 3, 2026 17:56
@github-actions github-actions Bot added the needs changelog Possibly needs a changelog entry label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs changelog Possibly needs a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant