Dpulicating "class Foo:" in C

Mark Charsley mark.charsley at REMOVE_THIS.radioscape.com
Mon Jul 22 07:04:00 EDT 2002


In article <mailman.1027098507.31935.python-list at python.org>, 
walter at livinglogic.de (=?ISO-8859-15?Q?Walter_D=F6rwald?=) wrote:

> > Is there any way to create a new Class Object from C without having 
> > to call into new.classobj?
> 
> In Include/classobject.h there's a
> PyObject *PyClass_New(PyObject *, PyObject *, PyObject *);
> 
> Arguments seem to be:
> * tuple of base classes
> * class attribute dictionary
> * class name

Which exactly matches new.classobj().


> But PyClass_New isn't documented, so I wonder, if it's
> part of the official API. At least, the function name does
> indicate that it is.

Well after a bit of googlin...

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/54352

seems to recommend its use and 

http://www.python.org/peps/pep-0253.html

includes the phrase 

"For a regular base class (or when no base class is specified), current 
Python calls PyClass_New(), the C level factory function for classes, 
directly."

So I'd guess that it's safe-ish to use. Still slightly worried about the 
lack of official documentation though. Thanks for the pointer.


-- 

Mark - personal opinion only, could well be wrong, not representing 
company, don't sue us etc. etc.



More information about the Python-list mailing list