Skip to content

[feat/precompile-internals] feat: move pybind11.h non-template definitions to pybind11-inl.h - #6136

Open
henryiii wants to merge 2 commits into
feat/precompile-internalsfrom
feat/precompile-pybind11-h
Open

[feat/precompile-internals] feat: move pybind11.h non-template definitions to pybind11-inl.h#6136
henryiii wants to merge 2 commits into
feat/precompile-internalsfrom
feat/precompile-pybind11-h

Conversation

@henryiii

@henryiii henryiii commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Description

Stacked on #6135. The headline slice of the pre-compilation split (~1,400 lines out of pybind11.h):

  • cpp_function: make_function_record, initialize_generic (~200 lines), destruct, and the ~440-line dispatcher move out of line. The templated initialize() and the constructors stay.
  • generic_type::initialize / mark_parents_nonsimple, enum_base::{init,value,export_values}.
  • Free functions: the function-signature generators, module cache helpers (get_cached_module etc.), keep_alive_impl, all_type_info_get_cache, get_type_override, register_exception_translator, detail::print, and the out-of-class error_already_set::what / m_fetched_error_deleter.

The descr.h constexpr machinery and all templates stay in the header. In precompiled mode the test module now measurably shrinks (the dispatcher and friends are compiled once into the static library instead of into every TU). Full test suite passes in both modes; header-only binary is byte-identical in size.

Suggested changelog entry:

  • Placeholder.

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

henryiii and others added 2 commits August 7, 2026 08:38
The headline of the split: cpp_function's make_function_record,
initialize_generic, destruct, and the 440-line dispatcher move out of
line, along with generic_type::initialize, enum_base, the function
signature generators, module cache helpers, keep_alive_impl,
get_type_override, error_already_set::what, and detail::print. The
templated initialize(), descr.h machinery, and the module/class_ API
stay in the header.

Assisted-by: ClaudeCode:claude-fable-5
@henryiii
henryiii force-pushed the feat/precompile-pybind11-h branch from ce07ef9 to e4fd93f 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