pytorch-inference
|
#include <py_object.hpp>
Public Member Functions | |
py_object () | |
py_object (PyObject *obj) | |
py_object (const std::string &package, const std::string &py_home="") | |
~py_object () | |
PyObject * | operator() (const std::string &attr) |
PyObject * | operator() (const std::string &attr, PyObject *args, PyObject *kwargs=NULL) |
PyObject * | operator() (const std::string &attr, std::initializer_list< PyObject *> arg) |
PyObject * | operator() (const std::string &attr, std::initializer_list< PyObject *> arg, std::initializer_list< PyObject *> kwarg) |
template<typename T > | |
void | operator() (const std::string &attr, T &cpp_retval) |
template<typename T > | |
void | operator() (const std::string &attr, T &cpp_retval, PyObject *args, PyObject *kwargs=NULL) |
template<typename T > | |
void | operator() (const std::string &attr, T &cpp_retval, std::initializer_list< PyObject *> arg) |
template<typename T > | |
void | operator() (const std::string &attr, T &cpp_retval, std::initializer_list< PyObject *> arg, std::initializer_list< PyObject *> kwarg) |
py_object | py_class (const std::string &klass, PyObject *args=NULL, PyObject *kwargs=NULL) |
Private Member Functions | |
void | check_callable (PyObject *obj) |
Private Attributes | |
PyObject * | me |
The core Python module. More... | |
Imports a python module and offers call operators to simplify calling member functions of that module from C++.
|
inline |
Default constructor - used internally only to make sure everything is working properly.
|
inline |
Allows for setting a py_object as a regular python object - as an object instead of a module or class. Also adds the object to the global namespace.
obj | The python object we're tring to set to Python |
|
inline |
Initializes a python module by starting the interpreter and importing the desired module.
package | The module to import. |
py_home | The home directory if it's different from pycpp::python_home (or the same, I don't judge) |
|
inline |
Destructor - cleans up the python references and finalizes the interpreter.
|
inlineprivate |
Checks if a PyObject * is callable - throws an error if it's not.
obj | PyObject * to check. |
|
inline |
Allows us to cleanly call functions that take no arguments.
attr | String that is exactly the name of a member function of the python module initialized. |
|
inline |
Given a string that is exactly a member function of a python module, calls that function with the given args and kwargs. args is a PyTuple and kwargs is a PyDict - the user can either create their own or use the pycpp functions make_tuple and make_dict provided here.
attr | String that is exactly the name of a member function of the python module initialized. |
args | PyTuple that holds the arguments to pass to the function. |
kwargs | PyDict that holds the keyword arguments to pass to the function. |
|
inline |
Given a string that is exactly a member function of a python module, calls that function with the given arguments as the function's args tuple. Creates a tuple of the arguments so that the function call can look like this: <py_object>("<function>", {pycpp::to_python("string"), pycpp::to_python(<value>)})
attr | String that is exactly the name of a member function of the python module initialized. |
args | The initializer list of PyObject * types that make up the args of the function |
|
inline |
Given a string that is exactly a member function of a python module, calls that function with the given arguments as the function's args tuple. Creates a tuple of the arguments so that the function call can look like this: <py_object>("<function>", {pycpp::to_python("string"), pycpp::to_python(<value>)})
attr | String that is exactly the name of a member function of the python module initialized. |
args | The initializer list of PyObject * types that make up the args of the function |
args | The initializer list of PyObject * types that make up the keyword args of the function |
|
inline |
Allows us to cleanly call functions that take no arguments.
T | The C++ type of the return value of the function |
attr | String that is exactly the name of a member function of the python module initialized. |
|
inline |
Given a string that is exactly a member function of a python module, calls that function with the given args and kwargs. args is a PyTuple and kwargs is a PyDict - the user can either create their own or use the pycpp functions make_tuple and make_dict provided here.
T | C++ type of return value of specified function |
attr | String that is exactly the name of a member function of the python module initialized. |
args | PyTuple that holds the arguments to pass to the function. |
kwargs | PyDict that holds the keyword arguments to pass to the function. |
|
inline |
Given a string that is exactly a member function of a python module, calls that function with the given arguments as the function's args tuple. Creates a tuple of the arguments so that the function call can look like this: <py_object>("<function>", {pycpp::to_python("string"), pycpp::to_python(<value>)})
T | C++ type of return value of specified function |
attr | String that is exactly the name of a member function of the python module initialized. |
args | The initializer list of PyObject * types that make up the args of the function |
|
inline |
Given a string that is exactly a member function of a python module, calls that function with the given arguments as the function's args tuple. Creates a tuple of the arguments so that the function call can look like this: <py_object>("<function>", {pycpp::to_python("string"), pycpp::to_python(<value>)}, {pybpp::to_python("kwarg_key"), pycpp::to_python("kwarg_arg")})
T | C++ type of return value of specified function |
attr | String that is exactly the name of a member function of the python module initialized. |
args | The initializer list of PyObject * types that make up the args of the function |
kwargs | The initializer list of PyObject *types that make up the keyword arguments of the function |
|
inline |
Imports a class from a package so that members of that class can be called upon. Name is under consideration for changes.
klass | The class that is being imported - like pandas.DataFrame (for example) |
|
private |
The core Python module.