pytorch-inference
py_object.hpp File Reference
#include <Python.h>
#include <stdexcept>
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <type_traits>

Go to the source code of this file.

Classes

class  pycpp::py_object
 

Namespaces

 pycpp
 

Macros

#define PYCPP_WHICH_PYTHON   "/usr/local/bin/ipython"
 This allows us to use the python interpreter that CMake finds or overload it. More...
 
#define PYCPP_PY_HOME   "../.."
 Gives us a smart value for the home directory - again from the CMake source directory. More...
 

Functions

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

Detailed Description

Todo:
: update docs

Holds the pycpp namespace. All the methods and functions related to importing Python modules and converting C++ values to python are here.

Macro Definition Documentation

◆ PYCPP_PY_HOME

#define PYCPP_PY_HOME   "../.."

Gives us a smart value for the home directory - again from the CMake source directory.

◆ PYCPP_WHICH_PYTHON

#define PYCPP_WHICH_PYTHON   "/usr/local/bin/ipython"

This allows us to use the python interpreter that CMake finds or overload it.