Pybind11's `py::smart_holder`: Unifying C++ Ownership

Introduced in pybind11 v3, `py::smart_holder` (or its shorthand `py::classh<T>`) is the recommended holder type, offering simultaneous two-way conversion support for both `std::shared_ptr` and `std::unique_ptr` and full integration with `std::enable_shared_from_this` for robust memory management.

Sources

Open the full topic