-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
At present, pybind11 docs for keep alive are as follows:
https://pybind11.readthedocs.io/en/stable/advanced/functions.html?highlight=keep_alive#keep-alive
https://github.com/pybind/pybind11/blob/v2.6.2/docs/advanced/functions.rst#keep-alive
Argument indices start at one, while zero refers to the return value. For methods, index
1refers to the implicitthispointer, while regular arguments begin at index2.
However, it doesn't cover cases like constructors, either via vanilla py::init(), or factory-style constructors, as indicated here:
https://pybind11.readthedocs.io/en/stable/advanced/classes.html#custom-constructors
I think we (Drake devs) operate under the assumption that a constructor functions as a method, and thus keep_alive<1, 2>() would be something like "Keep alive: self keeps first arg alive", but I'm not sure upon reinspection.
Motivation: RobotLocomotion/drake#14925 (review)
\cc @hongkai-dai