FAQ
i want make a new object named 'vector' to my python release,
the 'vector' is most like a 'list', but have some number operatioins
such as add, sub, ect. i create the head file vectorobject.h based
on listobject.h, i create the src file vectorobject.c based on
listobject.c and intobject.c.
1 i had create PyVectorObject like this
typedef struct {
PyObject_VAR_HEAD
double* ob_item;
} PyVectorObject;

2 i had create the PyVector_Type like this
PyAPI_DATA(PyTypeObject);
and initialize it in vectorobject.c like
PyTypeObject PyVector_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
"vector",
sizeof(PyVectorObject),
0,
(destructor)vector_dealloc, /* tp_dealloc */
(printfunc)vector_print, /* tp_print */
0, /* tp_getattr
*/
0, /* tp_setattr
*/
0, /* tp_compare */
0, /* tp_repr */
&vector_as_number, /*
tp_as_number */
0, /*
tp_as_sequence */
0, /*
tp_as_mapping */
...

but it dosen't works, i can't declare the object and used it, who
can tell me how to do, thanks very much.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedOct 15, '03 at 3:22a
activeOct 15, '03 at 3:22a
posts1
users1
websitepython.org

1 user in discussion

Elsejj: 1 post

People

Translate

site design / logo © 2022 Grokbase