pytorch-inference
pycpp Namespace Reference

Classes

class  py_object
 

Functions

PyObject * to_python (const std::vector< int > &vec)
 Takes a vector to a python list. More...
 
PyObject * to_python (std::vector< int > &&vec)
 Takes a vector to a python list. More...
 
PyObject * to_python (const std::vector< long > &vec)
 
PyObject * to_python (std::vector< long > &&vec)
 
PyObject * to_python (const std::vector< double > &vec)
 
PyObject * to_python (std::vector< double > &&vec)
 
PyObject * to_python (const std::vector< float > &vec)
 
PyObject * to_python (std::vector< float > &&vec)
 
PyObject * to_python (const std::vector< std::string > &vec)
 
PyObject * to_python (std::vector< std::string > &&vec)
 
PyObject * to_python (const int &num)
 Takes an int to a python int. Thin wrapper around PyLong _FromLong. More...
 
PyObject * to_python (int &&num)
 Takes an int to a python int. Thin wrapper around PyLong _FromLong. More...
 
PyObject * to_python (const long &num)
 Takes a long to a python int. Thin wrapper around PyLong _FromLong. More...
 
PyObject * to_python (long &&num)
 Takes a long to a python int. Thin wrapper around PyLong _FromLong. More...
 
PyObject * to_python (const float &num)
 Takes a float to a python float. Thin wrapper around PyFloat_FromDouble. More...
 
PyObject * to_python (float &&num)
 Takes a float to a python float. Thin wrapper around PyFloat_FromDouble. More...
 
PyObject * to_python (const double &num)
 Takes a double to a python float. Thin wrapper around PyFloat_FromDouble. More...
 
PyObject * to_python (double &&num)
 Takes a double to a python float. Thin wrapper around PyFloat_FromDouble. More...
 
PyObject * to_python (const std::string &str)
 Takes an std::string to a Python string. Thin wrapper around PyUnicode_FromString. More...
 
PyObject * to_python (std::string &&str)
 Takes an std::string to a Python string. Thin wrapper around PyUnicode_FromString. More...
 
PyObject * to_python (const char *str)
 Takes a char * to a Python string. Thin wrapper around PyUnicode_FromString. More...
 
PyObject * to_python (char *str)
 Takes a char * to a Python string. Thin wrapper around PyUnicode_FromString. More...
 
void from_python (PyObject *pyobj, std::string &cppobj)
 String specialization. More...
 
void from_python (PyObject *pyobj, int &cppobj)
 Int specialization. More...
 
void from_python (PyObject *pyobj, long &cppobj)
 Long specialization. More...
 
void from_python (PyObject *pyobj, float &cppobj)
 Float specialization. More...
 
void from_python (PyObject *pyobj, double &cppobj)
 Double specialization. More...
 
void from_python (PyObject *pyobj, std::vector< std::string > &cppobj)
 String vector specialization. More...
 
void from_python (PyObject *pyobj, std::vector< int > &cppobj)
 Int vector specialization. More...
 
void from_python (PyObject *pyobj, std::vector< long > &cppobj)
 Long vector specialization. More...
 
void from_python (PyObject *pyobj, std::vector< float > &cppobj)
 Float vector specialization. More...
 
void from_python (PyObject *pyobj, std::vector< double > &cppobj)
 Double vector specialization. More...
 
PyObject * make_tuple (std::initializer_list< PyObject *> l)
 Makes a PyTuple. More...
 
PyObject * make_tuple (std::vector< PyObject *> l)
 Makes a PyTuple. More...
 
PyObject * make_dict (std::initializer_list< PyObject *> l)
 Makes a PyDict. More...
 

Function Documentation

◆ from_python() [1/10]

void pycpp::from_python ( PyObject *  pyobj,
std::string &  cppobj 
)
inline

String specialization.

◆ from_python() [2/10]

void pycpp::from_python ( PyObject *  pyobj,
int &  cppobj 
)
inline

Int specialization.

◆ from_python() [3/10]

void pycpp::from_python ( PyObject *  pyobj,
long &  cppobj 
)
inline

Long specialization.

◆ from_python() [4/10]

void pycpp::from_python ( PyObject *  pyobj,
float &  cppobj 
)
inline

Float specialization.

◆ from_python() [5/10]

void pycpp::from_python ( PyObject *  pyobj,
double &  cppobj 
)
inline

Double specialization.

◆ from_python() [6/10]

void pycpp::from_python ( PyObject *  pyobj,
std::vector< std::string > &  cppobj 
)
inline

String vector specialization.

◆ from_python() [7/10]

void pycpp::from_python ( PyObject *  pyobj,
std::vector< int > &  cppobj 
)
inline

Int vector specialization.

◆ from_python() [8/10]

void pycpp::from_python ( PyObject *  pyobj,
std::vector< long > &  cppobj 
)
inline

Long vector specialization.

◆ from_python() [9/10]

void pycpp::from_python ( PyObject *  pyobj,
std::vector< float > &  cppobj 
)
inline

Float vector specialization.

◆ from_python() [10/10]

void pycpp::from_python ( PyObject *  pyobj,
std::vector< double > &  cppobj 
)
inline

Double vector specialization.

◆ make_dict()

PyObject* pycpp::make_dict ( std::initializer_list< PyObject *>  l)
inline

Makes a PyDict.

Makes a python dictionary for the purpose of passing keyword arguments. Note that the order of arguments is as follows: make_dict({pycpp::to_python("key_n"), pycpp::to_python(<value_n>)}) where n is the total number of key-value PAIRS.

Parameters
lThe initializer_list of key-value pairs.
Returns
A PyDict that can be passed directly to the py_object operator() call.

◆ make_tuple() [1/2]

PyObject* pycpp::make_tuple ( std::initializer_list< PyObject *>  l)
inline

Makes a PyTuple.

Makes a python tuple for the purpose of passing arguments to a python function. All arguments to this function MUST be of type PyObject * as follows: make_tuple({pycpp::to_python(<value_1>), pycpp::to_python(<value_2>)})

Parameters
lThe initializer list of arguments to be put into the tuple.
Returns
A PyTuple that can be passed directly to the py_object operator() call.

◆ make_tuple() [2/2]

PyObject* pycpp::make_tuple ( std::vector< PyObject *>  l)
inline

Makes a PyTuple.

Makes a python tuple for the purpose of passing arguments to a python function. All arguments to this function MUST be of type PyObject * as follows: make_tuple({pycpp::to_python(<value_1>), pycpp::to_python(<value_2>)})

Parameters
lThe vector of arguments to be put into the tuple.
Returns
A PyTuple that can be passed directly to the py_object operator() call.

◆ to_python() [1/22]

PyObject* pycpp::to_python ( const std::vector< int > &  vec)
inline

Takes a vector to a python list.

Parameters
vecVector of ints to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [2/22]

PyObject* pycpp::to_python ( std::vector< int > &&  vec)
inline

Takes a vector to a python list.

Parameters
vecVector of ints to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [3/22]

PyObject* pycpp::to_python ( const std::vector< long > &  vec)
inline
Parameters
vecVector of longs to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [4/22]

PyObject* pycpp::to_python ( std::vector< long > &&  vec)
inline
Parameters
vecVector of longs to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [5/22]

PyObject* pycpp::to_python ( const std::vector< double > &  vec)
inline
Parameters
vecVector of doubles to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [6/22]

PyObject* pycpp::to_python ( std::vector< double > &&  vec)
inline
Parameters
vecVector of doubles to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [7/22]

PyObject* pycpp::to_python ( const std::vector< float > &  vec)
inline
Parameters
vecVector of floats to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [8/22]

PyObject* pycpp::to_python ( std::vector< float > &&  vec)
inline
Parameters
vecVector of floats to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [9/22]

PyObject* pycpp::to_python ( const std::vector< std::string > &  vec)
inline
Parameters
vecVector of strings to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [10/22]

PyObject* pycpp::to_python ( std::vector< std::string > &&  vec)
inline
Parameters
vecVector of strings to take to a Python list.
Returns
A python list ready to be put into an appropriate pycpp function.

◆ to_python() [11/22]

PyObject* pycpp::to_python ( const int &  num)
inline

Takes an int to a python int. Thin wrapper around PyLong _FromLong.

Parameters
numNumeric value to be converted
Returns
A python int ready to be put into an appropriate pycpp function.

◆ to_python() [12/22]

PyObject* pycpp::to_python ( int &&  num)
inline

Takes an int to a python int. Thin wrapper around PyLong _FromLong.

Parameters
numNumeric value to be converted
Returns
A python int ready to be put into an appropriate pycpp function.

◆ to_python() [13/22]

PyObject* pycpp::to_python ( const long &  num)
inline

Takes a long to a python int. Thin wrapper around PyLong _FromLong.

Parameters
numNumeric value to be converted
Returns
A python int ready to be put into an appropriate pycpp function.

◆ to_python() [14/22]

PyObject* pycpp::to_python ( long &&  num)
inline

Takes a long to a python int. Thin wrapper around PyLong _FromLong.

Parameters
numNumeric value to be converted
Returns
A python int ready to be put into an appropriate pycpp function.

◆ to_python() [15/22]

PyObject* pycpp::to_python ( const float &  num)
inline

Takes a float to a python float. Thin wrapper around PyFloat_FromDouble.

Parameters
numNumeric value to be converted
Returns
A python float ready to be put into an appropriate pycpp function.

◆ to_python() [16/22]

PyObject* pycpp::to_python ( float &&  num)
inline

Takes a float to a python float. Thin wrapper around PyFloat_FromDouble.

Parameters
numNumeric value to be converted
Returns
A python float ready to be put into an appropriate pycpp function.

◆ to_python() [17/22]

PyObject* pycpp::to_python ( const double &  num)
inline

Takes a double to a python float. Thin wrapper around PyFloat_FromDouble.

Parameters
numNumeric value to be converted
Returns
A python float ready to be put into an appropriate pycpp function.

◆ to_python() [18/22]

PyObject* pycpp::to_python ( double &&  num)
inline

Takes a double to a python float. Thin wrapper around PyFloat_FromDouble.

Parameters
numNumeric value to be converted
Returns
A python float ready to be put into an appropriate pycpp function.

◆ to_python() [19/22]

PyObject* pycpp::to_python ( const std::string &  str)
inline

Takes an std::string to a Python string. Thin wrapper around PyUnicode_FromString.

Parameters
strThe std::string to be converted
Returns
A python string ready to be put into an appropriate pycpp function.

◆ to_python() [20/22]

PyObject* pycpp::to_python ( std::string &&  str)
inline

Takes an std::string to a Python string. Thin wrapper around PyUnicode_FromString.

Parameters
strThe std::string to be converted
Returns
A python string ready to be put into an appropriate pycpp function.

◆ to_python() [21/22]

PyObject* pycpp::to_python ( const char *  str)
inline

Takes a char * to a Python string. Thin wrapper around PyUnicode_FromString.

Parameters
strThe char * to be converted
Returns
A python string ready to be put into an appropriate pycpp function.

◆ to_python() [22/22]

PyObject* pycpp::to_python ( char *  str)
inline

Takes a char * to a Python string. Thin wrapper around PyUnicode_FromString.

Parameters
strThe char * to be converted
Returns
A python string ready to be put into an appropriate pycpp function.