This issue pertains to another complication involving pointers: The management of heap object lifetimes within pybind11 remains somewhat enigmatic.
By default, pybind11 presupposes that the lifespan of all heap objects will be regulated by the Python Garbage Collection system.
Consequently, pybind11 inherently supports only T* and std::unique_ptr<T>. In the case of T*, it is assumed that each pointer references either a newly created or an existing object. Meanwhile, std::unique_ptr<T> is permissible solely as a return type, invariably pointing to a newly instantiated object.
Should your API diverge from this paradigm, extensive coding involving Holder and Call Policy becomes imperative.
Currently, Pybind11-Weaver offers no solutions for managing these lifetimes; thus, if your API deviates from the default configuration of pybind11, the resultant code will also fail to serve your needs, necessitating the crafting of bespoke code to integrate these APIs.
I propose two potential enhancements:
- Introduce additional options to enable users to dictate the container type for each class.
- Implement support for specific C++ inline comment markers, such as
/*return_policy=take_ownership*/, to facilitate accurate call policy determination by pybind11-weaver.
This issue pertains to another complication involving pointers: The management of heap object lifetimes within pybind11 remains somewhat enigmatic.
By default, pybind11 presupposes that the lifespan of all heap objects will be regulated by the Python Garbage Collection system.
Consequently, pybind11 inherently supports only
T*andstd::unique_ptr<T>. In the case ofT*, it is assumed that each pointer references either a newly created or an existing object. Meanwhile,std::unique_ptr<T>is permissible solely as a return type, invariably pointing to a newly instantiated object.Should your API diverge from this paradigm, extensive coding involving Holder and Call Policy becomes imperative.
Currently, Pybind11-Weaver offers no solutions for managing these lifetimes; thus, if your API deviates from the default configuration of pybind11, the resultant code will also fail to serve your needs, necessitating the crafting of bespoke code to integrate these APIs.
I propose two potential enhancements:
/*return_policy=take_ownership*/, to facilitate accurate call policy determination by pybind11-weaver.