mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-23 05:35:13 +00:00
b4498ef44d
Allows checking the Python types before creating an object instead of after. For example: ```c++ auto l = list(ptr, true); if (l.check()) // ... ``` The above is replaced with: ```c++ if (isinstance<list>(ptr)) { auto l = reinterpret_borrow(ptr); // ... } ``` This deprecates `py::object::check()`. `py::isinstance()` covers the same use case, but it can also check for user-defined types: ```c++ class Pet { ... }; py::class_<Pet>(...); m.def("is_pet", [](py::object obj) { return py::isinstance<Pet>(obj); // works as expected }); ``` |
||
---|---|---|
.. | ||
attr.h | ||
cast.h | ||
chrono.h | ||
common.h | ||
complex.h | ||
descr.h | ||
eigen.h | ||
eval.h | ||
functional.h | ||
numpy.h | ||
operators.h | ||
options.h | ||
pybind11.h | ||
pytypes.h | ||
stl_bind.h | ||
stl.h | ||
typeid.h |