pycxx

Python cannot create instances

I am trying to create a simple Python extension using [PyCXX]. And I'm compiling against my Python 2.5 installation. My goal is to be able to do the following in Python: import Cats kitty = Cats.Kitty() if type(kitty) == Cats.Kitty: kitty.Speak() But every time I try, this is the error that I get: TypeError: cannot create 'Kit...

Creating an inheritable Python type with PyCxx

A friend and I have been toying around with various Python C++ wrappers lately, trying to find one that meets the needs of both some professional and hobby projects. We've both honed in on PyCxx as a good balance between being lightweight and easy to interface with while hiding away some of the ugliest bits of the Python C api. PyCxx is ...

How to access numpy array within PyCXX

Hi. I would like to convert numpy array to some double* or stl vector on the c++ side. I'm actually using PyCXX for this and I can't figure out the way to access the data. I'm currently able to access and return the data buffer like this : Py::Object arrayShape(const Py::Tuple& args ){ Py::Object array= args[0]; return arra...

PyCXX: How to construct an instance of a user defined new style class from C++ code?

I am using PyCXX to write an extension that exposes multiple (new style) classes to Python. A method of one of the classes (say A) needs to return an instance of another (say B) of these classes. I can't see an obvious way of constructing an instance of B from within C++ code. The constructors of new style classes require a PythonClass...