![]() |
Scarab
v2.9.1
Project 8 C++ Utility Library
|
glibc defines I as a macro which breaks things, e.g., boost template names More...
Namespaces | |
| __main__ | |
| _version | |
| detail | |
| literals | |
Classes | |
| struct | arg |
| struct | arg_v |
| class | args |
| struct | arithmetic |
| Annotation to mark enums as an arithmetic type. More... | |
| class | array |
| class | array_t |
| struct | base |
| Annotation indicating that a class derives from another given type. More... | |
| class | bool_ |
| class | buffer |
| class | buffer_error |
| struct | buffer_info |
| Information record describing a Python buffer object. More... | |
| struct | buffer_protocol |
| Annotation which enables the buffer protocol for a type. More... | |
| class | builtin_exception |
| C++ bindings of builtin Python exceptions. More... | |
| class | bytes |
| struct | call_guard |
| struct | call_guard< T > |
| struct | call_guard< T, Ts... > |
| struct | call_guard<> |
| class | capsule |
| class | cast_error |
| class | class_ |
| class | cpp_function |
| Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object. More... | |
| class | dict |
| struct | doc |
| Annotation for documentation. More... | |
| class | dtype |
| struct | dynamic_attr |
Annotation which enables dynamic attributes, i.e. adds __dict__ to a class. More... | |
| class | enum_ |
| Binds C++ enumerations and enumeration classes to Python. More... | |
| class | error_already_set |
| struct | error_scope |
| RAII wrapper that temporarily clears any Python error state. More... | |
| class | exception |
| class | float_ |
| struct | format_descriptor |
| struct | format_descriptor< char[N]> |
| struct | format_descriptor< std::array< char, N > > |
| struct | format_descriptor< std::complex< T >, detail::enable_if_t< std::is_floating_point< T >::value > > |
| struct | format_descriptor< T, detail::enable_if_t< detail::array_info< T >::is_array > > |
| struct | format_descriptor< T, detail::enable_if_t< detail::is_pod_struct< T >::value > > |
| struct | format_descriptor< T, detail::enable_if_t< std::is_arithmetic< T >::value > > |
| struct | format_descriptor< T, detail::enable_if_t< std::is_enum< T >::value > > |
| class | function |
| class | gil_scoped_acquire |
| class | gil_scoped_release |
| class | handle |
| class | index_error |
| class | int_ |
| struct | is_method |
| Annotation for methods. More... | |
| struct | is_operator |
| Annotation for operators. More... | |
| class | iterable |
| class | iterator |
| struct | keep_alive |
| Keep patient alive while nurse lives. More... | |
| class | key_error |
| class | kwargs |
| class | list |
| class | memoryview |
| struct | metaclass |
| Annotation which requests that a special metaclass is created for a type. More... | |
| class | module |
| Wrapper for Python extension modules. More... | |
| struct | module_local |
| Annotation that marks a class as local to the module: More... | |
| struct | multiple_inheritance |
| Annotation indicating that a class is involved in a multiple inheritance relationship. More... | |
| struct | name |
| Annotation for function names. More... | |
| struct | nodelete |
| Dummy destructor wrapper that can be used to expose classes with a private destructor. More... | |
| class | none |
| class | object |
| class | options |
| struct | overload_cast |
| struct | polymorphic_type_hook |
| struct | polymorphic_type_hook< itype, detail::enable_if_t< std::is_base_of< Animal, itype >::value > > |
| struct | polymorphic_type_hook< itype, detail::enable_if_t< std::is_polymorphic< itype >::value > > |
| class | reference_cast_error |
| Thrown when pybind11::cast or handle::call fail due to a type casting error. More... | |
| struct | scope |
| Annotation for parent scope. More... | |
| class | scoped_estream_redirect |
| class | scoped_interpreter |
| class | scoped_ostream_redirect |
| class | sequence |
| class | set |
| struct | sibling |
| Annotation indicating that a function is an overload associated with a given "sibling". More... | |
| class | slice |
| class | staticmethod |
| class | stop_iteration |
| class | str |
| class | tuple |
| class | type_error |
| class | value_error |
| class | weakref |
Typedefs | |
| template<typename > | |
| using | arg_t = arg_v |
| Alias for backward compatibility – to be removed in version 2.0. More... | |
| using | ssize_t = Py_ssize_t |
| using | size_t = std::size_t |
| using | EigenDStride = Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > |
| template<typename MatrixType > | |
| using | EigenDRef = Eigen::Ref< MatrixType, 0, EigenDStride > |
| template<typename MatrixType > | |
| using | EigenDMap = Eigen::Map< MatrixType, 0, EigenDStride > |
Enumerations | |
| enum | return_value_policy : uint8_t { automatic = 0, automatic_reference, take_ownership, copy, move, reference, reference_internal } |
| Approach used to cast a previously unknown C++ instance into a Python object. More... | |
| enum | eval_mode { eval_expr, eval_single_statement, eval_statements } |
Functions | |
| template<typename T , detail::enable_if_t<!detail::is_pyobject< T >::value, int > = 0> | |
| T | cast (const handle &handle) |
| template<typename T , detail::enable_if_t<!detail::is_pyobject< T >::value, int > = 0> | |
| object | cast (const T &value, return_value_policy policy=return_value_policy::automatic_reference, handle parent=handle()) |
| template<typename T > | |
| detail::enable_if_t<!detail::move_never< T >::value, T > | move (object &&obj) |
| template<typename T > | |
| detail::enable_if_t< detail::move_always< T >::value, T > | cast (object &&object) |
| template<typename T > | |
| detail::enable_if_t< detail::move_if_unreferenced< T >::value, T > | cast (object &&object) |
| template<typename T > | |
| detail::enable_if_t< detail::move_never< T >::value, T > | cast (object &&object) |
| template<return_value_policy policy = return_value_policy::automatic_reference> | |
| tuple | make_tuple () |
| template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args> | |
| tuple | make_tuple (Args &&... args_) |
| __attribute__ ((noinline)) inline void pybind11_fail(const char *reason) | |
| Used internally. More... | |
| template<typename T > | |
| T & | get_or_create_shared_data (const std::string &name) |
| template<typename T > | |
| static std::string | type_id () |
| Return a string representation of a C++ type. More... | |
| void | initialize_interpreter (bool init_signal_handlers=true) |
| void | finalize_interpreter () |
| template<eval_mode mode = eval_expr> | |
| object | eval (str expr, object global=globals(), object local=object()) |
| template<eval_mode mode = eval_expr, size_t N> | |
| object | eval (const char(&s)[N], object global=globals(), object local=object()) |
| void | exec (str expr, object global=globals(), object local=object()) |
| template<size_t N> | |
| void | exec (const char(&s)[N], object global=globals(), object local=object()) |
| template<eval_mode mode = eval_statements> | |
| object | eval_file (str fname, object global=globals(), object local=object()) |
| class_< detail::OstreamRedirect > | add_ostream_redirect (module m, std::string name="ostream_redirect") |
| template<typename Return , typename... Args> | |
| detail::vectorize_helper< Return(*)(Args...), Return, Args... > | vectorize (Return(*f)(Args ...)) |
| template<typename Func , detail::enable_if_t< detail::is_lambda< Func >::value, int > = 0> | |
| auto | vectorize (Func &&f) -> decltype(detail::vectorize_extractor(std::forward< Func >(f),(detail::function_signature_t< Func > *) nullptr)) |
| template<typename Return , typename Class , typename... Args, typename Helper = detail::vectorize_helper<decltype(std::mem_fn(std::declval<Return (Class::*)(Args...)>())), Return, Class *, Args...>> | |
| Helper | vectorize (Return(Class::*f)(Args...)) |
| dict | globals () |
| template<typename , typename F > | |
| auto | method_adaptor (F &&f) -> decltype(std::forward< F >(f)) |
| template<typename Derived , typename Return , typename Class , typename... Args> | |
| auto | method_adaptor (Return(Class::*pmf)(Args...)) -> Return(Derived::*)(Args...) |
| template<typename... Args> | |
| detail::initimpl::constructor< Args... > | init () |
| Binds an existing constructor taking arguments Args... More... | |
| template<typename... Args> | |
| detail::initimpl::alias_constructor< Args... > | init_alias () |
| template<typename Func , typename Ret = detail::initimpl::factory<Func>> | |
| Ret | init (Func &&f) |
| Binds a factory function as a constructor. More... | |
| template<typename CFunc , typename AFunc , typename Ret = detail::initimpl::factory<CFunc, AFunc>> | |
| Ret | init (CFunc &&c, AFunc &&a) |
| template<typename GetState , typename SetState > | |
| detail::initimpl::pickle_factory< GetState, SetState > | pickle (GetState &&g, SetState &&s) |
| template<return_value_policy Policy = return_value_policy::reference_internal, typename Iterator , typename Sentinel , typename ValueType = decltype(*std::declval<Iterator>()), typename... Extra> | |
| iterator | make_iterator (Iterator first, Sentinel last, Extra &&... extra) |
| Makes a python iterator from a first and past-the-end C++ InputIterator. More... | |
| template<return_value_policy Policy = return_value_policy::reference_internal, typename Iterator , typename Sentinel , typename KeyType = decltype((*std::declval<Iterator>()).first), typename... Extra> | |
| iterator | make_key_iterator (Iterator first, Sentinel last, Extra &&... extra) |
| template<return_value_policy Policy = return_value_policy::reference_internal, typename Type , typename... Extra> | |
| iterator | make_iterator (Type &value, Extra &&... extra) |
| template<return_value_policy Policy = return_value_policy::reference_internal, typename Type , typename... Extra> | |
| iterator | make_key_iterator (Type &value, Extra &&... extra) |
| template<typename InputType , typename OutputType > | |
| void | implicitly_convertible () |
| template<typename ExceptionTranslator > | |
| void | register_exception_translator (ExceptionTranslator &&translator) |
| template<typename CppException > | |
| exception< CppException > & | register_exception (handle scope, const char *name, PyObject *base=PyExc_Exception) |
| template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args> | |
| void | print (Args &&...args) |
| function | get_type_overload (const void *this_ptr, const detail::type_info *this_type, const char *name) |
| template<class T > | |
| function | get_overload (const T *this_ptr, const char *name) |
| template<typename T > | |
| T | reinterpret_borrow (handle h) |
| template<typename T > | |
| T | reinterpret_steal (handle h) |
| template<typename T , detail::enable_if_t< std::is_base_of< object, T >::value, int > = 0> | |
| bool | isinstance (handle obj) |
| template<> | |
| bool | isinstance< handle > (handle obj)=delete |
| template<> | |
| bool | isinstance< object > (handle obj) |
| bool | isinstance (handle obj, handle type) |
| bool | hasattr (handle obj, handle name) |
| bool | hasattr (handle obj, const char *name) |
| void | delattr (handle obj, handle name) |
| void | delattr (handle obj, const char *name) |
| 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_) |
| void | setattr (handle obj, handle name, handle value) |
| void | setattr (handle obj, const char *name, handle value) |
| ssize_t | hash (handle obj) |
| size_t | len (handle h) |
| size_t | len_hint (handle h) |
| str | repr (handle h) |
| iterator | iter (handle obj) |
| std::ostream & | operator<< (std::ostream &os, const handle &obj) |
| template<typename Vector , typename holder_type = std::unique_ptr<Vector>, typename... Args> | |
| class_< Vector, holder_type > | bind_vector (handle scope, std::string const &name, Args &&... args) |
| template<typename Map , typename holder_type = std::unique_ptr<Map>, typename... Args> | |
| class_< Map, holder_type > | bind_map (handle scope, const std::string &name, Args &&... args) |
| def | get_include (user=False) |
Variables | |
| static constexpr auto | const_ = std::true_type{} |
glibc defines I as a macro which breaks things, e.g., boost template names
| using EigenDMap = Eigen::Map<MatrixType, 0, EigenDStride> |
| using EigenDRef = Eigen::Ref<MatrixType, 0, EigenDStride> |
| using EigenDStride = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> |
| using size_t = std::size_t |
Definition at line 299 of file detail/common.h.
| using ssize_t = Py_ssize_t |
Definition at line 298 of file detail/common.h.
| enum eval_mode |
|
strong |
Approach used to cast a previously unknown C++ instance into a Python object.
| Enumerator | |
|---|---|
| automatic | This is the default return value policy, which falls back to the policy return_value_policy::take_ownership when the return value is a pointer. Otherwise, it uses return_value::move or return_value::copy for rvalue and lvalue references, respectively. See below for a description of what all of these different policies do. |
| automatic_reference | As above, but use policy return_value_policy::reference when the return value is a pointer. This is the default conversion policy for function arguments when calling Python functions manually from C++ code (i.e. via handle::operator()). You probably won't need to use this. |
| take_ownership | Reference an existing object (i.e. do not create a new copy) and take ownership. Python will call the destructor and delete operator when the object’s reference count reaches zero. Undefined behavior ensues when the C++ side does the same.. |
| copy | Create a new copy of the returned object, which will be owned by Python. This policy is comparably safe because the lifetimes of the two instances are decoupled. |
| move | Use std::move to move the return value contents into a new instance that will be owned by Python. This policy is comparably safe because the lifetimes of the two instances (move source and destination) are decoupled. |
| reference | Reference an existing object, but do not take ownership. The C++ side is responsible for managing the object’s lifetime and deallocating it when it is no longer used. Warning: undefined behavior will ensue when the C++ side deletes an object that is still referenced and used by Python. |
| reference_internal | This policy only applies to methods and properties. It references the object without taking ownership similar to the above return_value_policy::reference policy. In contrast to that policy, the function or property’s implicit this argument (called the parent) is considered to be the the owner of the return value (the child). pybind11 then couples the lifetime of the parent to the child via a reference relationship that ensures that the parent cannot be garbage collected while Python is still using the child. More advanced variations of this scheme are also possible using combinations of return_value_policy::reference and the keep_alive call policy |
Definition at line 302 of file detail/common.h.
|
inline |
Used internally.
Set the shared data that can be later recovered by get_shared_data().
Returns a named pointer that is shared among all extension modules (using the same pybind11 version) running in the current interpreter. Names starting with underscores are reserved for internal usage. Returns nullptr if no matching entry was found.
Definition at line 680 of file detail/common.h.
|
inline |
This is a helper function to add a C++ redirect context manager to Python instead of using a C++ guard. To use it, add the following to your binding code:
.. code-block:: cpp
#include <pybind11/iostream.h> ... py::add_ostream_redirect(m, "ostream_redirect");
You now have a Python context manager that redirects your output:
.. code-block:: python
with m.ostream_redirect():
m.print_to_cout_function()
This manager can optionally be told which streams to operate on:
.. code-block:: python
with m.ostream_redirect(stdout=true, stderr=true):
m.noisy_function_with_error_printing()
Definition at line 202 of file iostream.h.
| class_<Map, holder_type> pybind11::bind_map | ( | handle | scope, |
| const std::string & | name, | ||
| Args &&... | args | ||
| ) |
Definition at line 576 of file stl_bind.h.
| class_<Vector, holder_type> pybind11::bind_vector | ( | handle | scope, |
| std::string const & | name, | ||
| Args &&... | args | ||
| ) |
Definition at line 415 of file stl_bind.h.
| object pybind11::cast | ( | const T & | value, |
| return_value_policy | policy = return_value_policy::automatic_reference, |
||
| handle | parent = handle() |
||
| ) |
| detail::enable_if_t<detail::move_always<T>::value, T> pybind11::cast | ( | object && | object | ) |
| detail::enable_if_t<detail::move_if_unreferenced<T>::value, T> pybind11::cast | ( | object && | object | ) |
| detail::enable_if_t<detail::move_never<T>::value, T> pybind11::cast | ( | object && | object | ) |
|
inline |
Shut down the Python interpreter. No pybind11 or CPython API functions can be called after this. In addition, pybind11 objects must not outlive the interpreter:
.. code-block:: cpp
{ // BAD
py::initialize_interpreter();
auto hello = py::str("Hello, World!");
py::finalize_interpreter();
} // <-- BOOM, hello's destructor is called after interpreter shutdown
{ // GOOD
py::initialize_interpreter();
{ // scoped
auto hello = py::str("Hello, World!");
} // <-- OK, hello is cleaned up properly
py::finalize_interpreter();
}
{ // BETTER
py::scoped_interpreter guard{};
auto hello = py::str("Hello, World!");
}
.. warning::
The interpreter can be restarted by calling `initialize_interpreter` again. Modules created using pybind11 can be safely re-initialized. However, Python itself cannot completely unload binary extension modules and there are several caveats with regard to interpreter restarting. All the details can be found in the CPython documentation. In short, not all interpreter memory may be freed, either due to reference cycles or user-created global data.
| def pybind11.get_include | ( | user = False | ) |
Definition at line 4 of file pybind11/__init__.py.
| T& pybind11::get_or_create_shared_data | ( | const std::string & | name | ) |
Returns a typed reference to a shared data entry (by using get_shared_data()) if such entry exists. Otherwise, a new object of default-constructible type T is added to the shared data under the given name and a reference to it is returned.
Definition at line 298 of file internals.h.
| function pybind11::get_overload | ( | const T * | this_ptr, |
| const char * | name | ||
| ) |
Try to retrieve a python method by the provided name from the instance pointed to by the this_ptr.
:this_ptr: The pointer to the object the overload should be retrieved for. This should be the first non-trampoline class encountered in the inheritance chain. :name: The name of the overloaded Python method to retrieve. :return: The Python method by this name from the object or an empty function wrapper.
Definition at line 2074 of file pybind11.h.
|
inline |
Definition at line 2009 of file pybind11.h.
| void pybind11::implicitly_convertible | ( | ) |
Definition at line 1723 of file pybind11.h.
| detail::initimpl::constructor<Args...> pybind11::init | ( | ) |
Binds an existing constructor taking arguments Args...
Definition at line 1371 of file pybind11.h.
| Ret pybind11::init | ( | Func && | f | ) |
Binds a factory function as a constructor.
Definition at line 1378 of file pybind11.h.
| Ret pybind11::init | ( | CFunc && | c, |
| AFunc && | a | ||
| ) |
Dual-argument factory function: the first function is called when no alias is needed, the second when an alias is needed (i.e. due to python-side inheritance). Arguments must be identical.
Definition at line 1383 of file pybind11.h.
| detail::initimpl::alias_constructor<Args...> pybind11::init_alias | ( | ) |
Like init<Args...>(), but the instance is always constructed through the alias class (even when not inheriting on the Python side).
Definition at line 1374 of file pybind11.h.
|
inline |
Initialize the Python interpreter. No other pybind11 or CPython API functions can be called before this is done; with the exception of PYBIND11_EMBEDDED_MODULE. The optional parameter can be used to skip the registration of signal handlers (see the Python documentation_ for details). Calling this function again after the interpreter has already been initialized is a fatal error.
If initializing the Python interpreter fails, then the program is terminated. (This is controlled by the CPython runtime and is an exception to pybind11's normal behavior of throwing exceptions on errors.)
.. _Python documentation: https://docs.python.org/3/c-api/init.html#c.Py_InitializeEx
|
inlinedelete |
|
inline |
| iterator pybind11::make_iterator | ( | Iterator | first, |
| Sentinel | last, | ||
| Extra &&... | extra | ||
| ) |
Makes a python iterator from a first and past-the-end C++ InputIterator.
Definition at line 1658 of file pybind11.h.
| iterator pybind11::make_iterator | ( | Type & | value, |
| Extra &&... | extra | ||
| ) |
Makes an iterator over values of an stl container or other container supporting std::begin()/std::end()
Definition at line 1712 of file pybind11.h.
| iterator pybind11::make_key_iterator | ( | Iterator | first, |
| Sentinel | last, | ||
| Extra &&... | extra | ||
| ) |
Makes an python iterator over the keys (.first) of a iterator over pairs from a first and past-the-end InputIterator.
Definition at line 1687 of file pybind11.h.
| iterator pybind11::make_key_iterator | ( | Type & | value, |
| Extra &&... | extra | ||
| ) |
Makes an iterator over the keys (.first) of a stl map-like container supporting std::begin()/std::end()
Definition at line 1719 of file pybind11.h.
| auto pybind11::method_adaptor | ( | F && | f | ) | -> decltype(std::forward<F>(f)) |
Given a pointer to a member function, cast it to its Derived version. Forward everything else unchanged.
Definition at line 1021 of file pybind11.h.
| auto method_adaptor | ( | Return(Class::*)(Args...) | pmf | ) | -> Return (Derived::*)(Args...) |
Definition at line 1024 of file pybind11.h.
| detail::enable_if_t<!detail::move_never<T>::value, T> pybind11::move | ( | object && | obj | ) |
|
inline |
| detail::initimpl::pickle_factory<GetState, SetState> pybind11::pickle | ( | GetState && | g, |
| SetState && | s | ||
| ) |
Binds pickling functions __getstate__ and __setstate__ and ensures that the type returned by __getstate__ is the same as the argument accepted by __setstate__.
Definition at line 1390 of file pybind11.h.
| void pybind11::print | ( | Args &&... | args | ) |
Definition at line 1849 of file pybind11.h.
| exception<CppException>& pybind11::register_exception | ( | handle | scope, |
| const char * | name, | ||
| PyObject * | base = PyExc_Exception |
||
| ) |
Registers a Python exception in m of the given name and installs an exception translator to translate the C++ exception to the created Python exception using the exceptions what() method. This is intended for simple exception translations; for more complex translation, register the exception object and translator directly.
Definition at line 1798 of file pybind11.h.
| void pybind11::register_exception_translator | ( | ExceptionTranslator && | translator | ) |
Definition at line 1751 of file pybind11.h.
| T pybind11::reinterpret_borrow | ( | handle | h | ) |
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
| T pybind11::reinterpret_steal | ( | handle | h | ) |
|
static |
| detail::vectorize_helper<Return (*)(Args...), Return, Args...> pybind11::vectorize | ( | Return(*)(Args ...) | f | ) |
| auto pybind11::vectorize | ( | Func && | f | ) | -> decltype( detail::vectorize_extractor(std::forward<Func>(f), (detail::function_signature_t<Func> *) nullptr)) |
|
static |
Const member function selector for overload_cast
Definition at line 756 of file detail/common.h.
1.8.13