We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
PyTypeObject
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I couldnt find if PyBind supports type objects. If not, then something like this is useful:
struct typeobject : py::handle { typeobject(PyTypeObject *type) : py::handle((PyObject*)type) { } typeobject static float_() { return typeobject(&PyFloat_Type); } typeobject static int_() { return typeobject(&PyInt_Type); } typeobject static str() { return typeobject(&PyString_Type); } };
or
py::handle typeobject(PyTypeObject *type) { return py::handle((PyObject*)type); } template<typename T> py::handle typeobject(); template<> py::handle typeobject<py::float_>() { return typeobject(&PyFloat_Type); } template<> py::handle typeobject<py::int_>() { return typeobject(&PyInt_Type); } template<> py::handle typeobject<py::str>() { return typeobject(&PyString_Type); }
for example handling type arguments module.def("foo", py::arg("bar") = typeobject::str());
module.def("foo", py::arg("bar") = typeobject::str());
The text was updated successfully, but these errors were encountered:
h.get_type()
py::type(h)
Successfully merging a pull request may close this issue.
I couldnt find if PyBind supports type objects. If not, then something like this is useful:
or
for example handling type arguments
module.def("foo", py::arg("bar") = typeobject::str());
The text was updated successfully, but these errors were encountered: