PyCObject subtype PyObject
bt98 at doc.ic.ac.uk
Mon Jun 10 12:47:11 CEST 2002
Michael Hudson wrote:
> > 2) For function "PyCObject_FromVoidPtr()", it takes in a "void*" as the
> > first argument.
> > For function "PyCObject_AsVoidPtr()", it returns a "void*".
> > When implementing Python extension, what is the potential danger of
> > casting pointers, of different size, to and from "void*"?
> Doesn't C guarantee that you can cast a pointer of type (T*) to
> (void*) and back again for all T? I was fairly sure it did.
I am extending a C++ application with Python. Before attempting other
possibilities, like Boost, I just want to document the work I have done so
Simply speaking I am hiding a C++ pointer, as a PyCObject*, inside a Python
The scheme works OK. The C++ class hierarchy is reflected by Python classes.
The pair of C++ and Python object is passed around between the two
> > 4) Apart from exporting function between modules, are there any
> > examples of using PyCObject?
The example, in the Python/C API document, is talking about exporting
functions between Python modules. So I am wondering if my method is valid?
Thanks for your feedback.
More information about the Python-list