PyCFunction? What is it?

Greg Ewing greg at cosc.canterbury.ac.nz
Mon May 29 22:49:08 EDT 2000


Stephen Hansen wrote:
> 
> What *is* PyCFunction and do method defs need to be cast to it?

It's the signature of a C function which implements a
Python function, defined in methodobject.h as:

typedef PyObject *(*PyCFunction) Py_FPROTO((PyObject *, PyObject *));

If you have declared your C function with a prototype, the
cast isn't necessary, because it will already have the
right signature. The casts in the cStringIO module seem
to be redundant -- maybe a hangover from some pre-ANSI
version of the code.

-- 
Greg Ewing, Computer Science Dept,
+--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-list mailing list