Go to the source code of this file.
Classes | |
class | accessor< Policy > |
class | accessor< Policy > |
class | args |
class | args_proxy |
struct | arrow_proxy< T > |
Quick proxy class needed to implement operator-> for iterators which can't return pointers. More... | |
class | bool_ |
struct | object::borrowed_t |
class | buffer |
class | bytes |
class | capsule |
class | dict |
class | dict_readonly |
Python's dictionary protocol permits this to be a forward iterator. More... | |
class | ellipsis |
class | error_already_set |
class | float_ |
class | function |
struct | generic_item |
class | generic_iterator< Policy > |
STL iterator template used for tuple, list, sequence and dict. More... | |
class | handle |
class | int_ |
class | iterable |
class | iterator |
class | kwargs |
class | kwargs_proxy |
class | list |
struct | list_item |
class | memoryview |
class | none |
struct | obj_attr |
class | object |
class | object_api< Derived > |
class | pyobject_tag |
Tag and check to identify a class which implements the Python object API. More... | |
class | sequence |
class | sequence_fast_readonly |
Lightweight iterator policy using just a simple pointer: see PySequence_Fast_ITEMS More... | |
struct | sequence_item |
class | sequence_slow_readwrite |
Full read and write access using the sequence protocol: see detail::sequence_accessor More... | |
class | set |
class | simple_collector< policy > |
class | slice |
class | staticmethod |
struct | object::stolen_t |
class | str |
struct | str_attr |
class | tuple |
struct | tuple_item |
class | type |
class | unpacking_collector< policy > |
Helper class which collects positional, keyword, * and ** arguments for a Python function call. More... | |
class | weakref |
Namespaces | |
accessor_policies | |
literals | |
Macros | |
#define | PYBIND11_MATH_OPERATOR_BINARY(op, fn) |
#define | PYBIND11_MATH_OPERATOR_UNARY(op, fn) |
#define | PYBIND11_OBJECT(Name, Parent, CheckFun) |
#define | PYBIND11_OBJECT_COMMON(Name, Parent, CheckFun) |
#define | PYBIND11_OBJECT_CVT(Name, Parent, CheckFun, ConvertFun) |
#define | PYBIND11_OBJECT_DEFAULT(Name, Parent, CheckFun) |
Typedefs | |
using | dict_iterator = generic_iterator< iterator_policies::dict_readonly > |
template<typename T > | |
using | is_ds_unpacking = std::is_same< kwargs_proxy, T > |
template<typename T > | |
using | is_keyword = std::is_base_of< arg, T > |
Python argument categories (using PEP 448 terms) More... | |
template<typename T > | |
using | is_keyword_or_ds = satisfies_any_of< T, is_keyword, is_ds_unpacking > |
template<typename T > | |
using | is_positional = satisfies_none_of< T, is_keyword, is_s_unpacking, is_ds_unpacking > |
template<typename T > | |
using | is_pyobject = std::is_base_of< pyobject_tag, remove_reference_t< T >> |
template<typename T > | |
using | is_s_unpacking = std::is_same< args_proxy, T > |
using | item_accessor = accessor< accessor_policies::generic_item > |
using | list_accessor = accessor< accessor_policies::list_item > |
using | list_iterator = generic_iterator< iterator_policies::sequence_fast_readonly > |
using | obj_attr_accessor = accessor< accessor_policies::obj_attr > |
using | sequence_accessor = accessor< accessor_policies::sequence_item > |
using | sequence_iterator = generic_iterator< iterator_policies::sequence_slow_readwrite > |
using | str_attr_accessor = accessor< accessor_policies::str_attr > |
using | tuple_accessor = accessor< accessor_policies::tuple_item > |
using | tuple_iterator = generic_iterator< iterator_policies::sequence_fast_readonly > |
Functions | |
template<typename Unsigned > | |
Unsigned | as_unsigned (PyObject *o) |
void | delattr (handle obj, handle name) |
void | delattr (handle obj, const char *name) |
std::string | error_string () |
handle | get_function (handle value) |
object | getattr (handle obj, handle name) |
object | getattr (handle obj, const char *name) |
object | getattr (handle obj, handle name, handle default_) |
object | getattr (handle obj, const char *name, handle default_) |
bool | hasattr (handle obj, handle name) |
bool | hasattr (handle obj, const char *name) |
ssize_t | hash (handle obj) |
template<typename T , detail::enable_if_t< std::is_base_of< object, T >::value, int > = 0> | |
bool | isinstance (handle obj) |
bool | isinstance (handle obj, handle type) |
template<> | |
bool | isinstance< handle > (handle)=delete |
template<> | |
bool | isinstance< object > (handle obj) |
bool | isinstance_generic (handle obj, const std::type_info &tp) |
iterator | iter (handle obj) |
size_t | len (handle h) |
size_t | len_hint (handle h) |
template<typename T , enable_if_t< is_pyobject< T >::value, int > = 0> | |
auto | object_or_cast (T &&o) -> decltype(std::forward< T >(o)) |
template<typename T , enable_if_t<!is_pyobject< T >::value, int > = 0> | |
object | object_or_cast (T &&o) |
handle | object_or_cast (PyObject *ptr) |
str | literals::operator""_s (const char *s, size_t size) |
bool | PyEllipsis_Check (PyObject *o) |
bool | PyIterable_Check (PyObject *obj) |
bool | PyNone_Check (PyObject *o) |
bool | PyStaticMethod_Check (PyObject *o) |
bool | PyUnicode_Check_Permissive (PyObject *o) |
template<typename T > | |
T | reinterpret_borrow (handle h) |
template<typename T > | |
T | reinterpret_steal (handle h) |
str | repr (handle h) |
void | setattr (handle obj, handle name, handle value) |
void | setattr (handle obj, const char *name, handle value) |
#define PYBIND11_MATH_OPERATOR_BINARY | ( | op, | |
fn | |||
) |
#define PYBIND11_MATH_OPERATOR_UNARY | ( | op, | |
fn | |||
) |
#define PYBIND11_OBJECT | ( | Name, | |
Parent, | |||
CheckFun | |||
) |
#define PYBIND11_OBJECT_COMMON | ( | Name, | |
Parent, | |||
CheckFun | |||
) |
#define PYBIND11_OBJECT_CVT | ( | Name, | |
Parent, | |||
CheckFun, | |||
ConvertFun | |||
) |
#define PYBIND11_OBJECT_DEFAULT | ( | Name, | |
Parent, | |||
CheckFun | |||
) |
using dict_iterator = generic_iterator<iterator_policies::dict_readonly> |
using is_ds_unpacking = std::is_same<kwargs_proxy, T> |
using is_keyword = std::is_base_of<arg, T> |
using is_keyword_or_ds = satisfies_any_of<T, is_keyword, is_ds_unpacking> |
using is_positional = satisfies_none_of<T, is_keyword, is_s_unpacking, is_ds_unpacking > |
using is_pyobject = std::is_base_of<pyobject_tag, remove_reference_t<T>> |
using is_s_unpacking = std::is_same<args_proxy, T> |
using item_accessor = accessor<accessor_policies::generic_item> |
using list_accessor = accessor<accessor_policies::list_item> |
using list_iterator = generic_iterator<iterator_policies::sequence_fast_readonly> |
using obj_attr_accessor = accessor<accessor_policies::obj_attr> |
using sequence_accessor = accessor<accessor_policies::sequence_item> |
using sequence_iterator = generic_iterator<iterator_policies::sequence_slow_readwrite> |
using str_attr_accessor = accessor<accessor_policies::str_attr> |
using tuple_accessor = accessor<accessor_policies::tuple_item> |
using tuple_iterator = generic_iterator<iterator_policies::sequence_fast_readonly> |
|
inlinedelete |
|
inline |
|
inline |
Declare that a handle
or PyObject *
is a certain type and borrow the reference. The target type T
must be object
or one of its derived classes. The function doesn't do any conversions or checks. It's up to the user to make sure that the target type is correct.
.. code-block:: cpp
PyObject *p = PyList_GetItem(obj, index); py::object o = reinterpret_borrow<py::object>(p);
or py::tuple t = reinterpret_borrow<py::tuple>(p); // <– p
must be already be a tuple