PyCFunction? What is it?

Mark Hammond mhammond at skippinet.com.au
Wed May 31 04:15:13 CEST 2000


"Fredrik Lundh" <effbot at telia.com> wrote in message
news:UNJY4.6205$wYl.223632896 at newsb.telia.net...
> To get the object pointer, you have to cast it back at some
> point, and some programmers prefer to write:
>
>     mymethod(MyOwnObject *self, PyObject *args)
>    {

Just FYI, this doesnt work if MyOwnObject happens to be a C++ object that
derives from a PyObject, and also has virtual methods.

In that case, you _must_ declare the function as taking a PyObject *, and
perform the cast Fredrik tries to avoid - the cast actually adjusts the
pointer generally by the size of the vtable pointer.

Mark.






More information about the Python-list mailing list