extending the builtin array class from C

Joachim Dahl joachim at ee.ucla.edu
Sat Aug 14 17:32:51 EDT 2004


I would like to inherit the builtin array class and write som extension 
methods in C. Other people have suggested that I use numarray for that,
but all I want is a simple continuous C array of doubles, and a way to
access the array directly from some C extension methods.

I thought it would be possible to change the "xxsubtype.c" to accomodate
my needs, but when it comes to actually defining the "array" class I am
a bit lost. There are no header files, so how do I define the "array type?

The init method for the spamdict type of xxsubtype.c module looks 
something like:

static int spamdict_init(spamdictobject *self, PyObject *args, PyObject 
*kwds)
{
	if (PyDict_Type.tp_init((PyObject *)self, args, kwds) < 0)
		return -1;
	self->state = 0;
	return 0;
}

How would I replace the PyDict_Type with an array type? Or is it not 
possible to extend all builtin classes from C?

Thanks,
Joachim



More information about the Python-list mailing list