PyCObject subtype PyObject
mwh at python.net
Mon Jun 10 11:52:41 CEST 2002
Benjamin Tai <bt98 at doc.ic.ac.uk> writes:
> Any comments to clarify my confusion would be appreciated.
> In Python/C API Reference Manual, section 7.5.9 CObjects, the document
> mentions that:
> "PyCObject This subtype of PyObject represents an opaque value, ..."
> 1) What does it mean by "subtype"? As a C interface, is the document
> talking about two structs which share some common fields?
> 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.
Python is implemented in C not C++, you know...
> 3) What if I can always determine the original type of the pointer?
> 4) Apart from exporting function between modules, are there any
> examples of using PyCObject?
Not sure what you mean here either...
The PROPER way to handle HTML postings is to cancel the article,
then hire a hitman to kill the poster, his wife and kids, and fuck
his dog and smash his computer into little bits. Anything more is
just extremism. -- Paul Tomblin, asr
More information about the Python-list