Creating Instance of Python Extension Type in C
Posted
by Brad Zeis
on Stack Overflow
See other posts from Stack Overflow
or by Brad Zeis
Published on 2010-04-03T23:38:42Z
Indexed on
2010/04/03
23:43 UTC
Read the original article
Hit count: 240
python
|extension-modules
I am writing a simple Vector
implementation as a Python extension module in C that looks mostly like this:
typedef struct {
PyObject_HEAD
double x;
double y;
} Vector;
static PyTypeObject Vector_Type = {
...
};
It is very simple to create instances of Vector
while calling from Python, but I need to create a Vector
instance in the same extension module. I looked in the documentation but I couldn't find a clear answer. What's the best way to do this?
© Stack Overflow or respective owner