You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear all,
How is it possible to use "guards" when importing a Python module generated by pybind, i.e. PYBIND11_MODULE ?
More specifically, I would like that, when writing import my_pybind_module
in python3, an (invisible) C++ object my_object is created, and that this object is deleted when stopping the python interpreter. This object contains the environment that is necessary for the module. Said in other words, I would like to code something in the pybind interface like #include <pybind11/pybind11.h> PYBIND11_MODULE(my_pybind_module, my_pybind_module, py::call_guard<my_object>()){ ... }
which is not possible.
Actually, I could create functions my_pybind_module.initialize() and my_pybind_module.delete(), but it would be tedious for the user to remember to write them at the beginning and at the end of their python script.
Thanks a lot for your help!
With kind regards,
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Dear all,
How is it possible to use "guards" when importing a Python module generated by pybind, i.e.
PYBIND11_MODULE
?More specifically, I would like that, when writing
import my_pybind_module
in python3, an (invisible) C++ object my_object is created, and that this object is deleted when stopping the python interpreter. This object contains the environment that is necessary for the module. Said in other words, I would like to code something in the pybind interface like
#include <pybind11/pybind11.h>
PYBIND11_MODULE(my_pybind_module, my_pybind_module, py::call_guard<my_object>()){
...
}
which is not possible.
Actually, I could create functions my_pybind_module.initialize() and my_pybind_module.delete(), but it would be tedious for the user to remember to write them at the beginning and at the end of their python script.
Thanks a lot for your help!
With kind regards,
Marc
Beta Was this translation helpful? Give feedback.
All reactions