Python C-API Object Allocation
William Newbery
wnewbery at hotmail.co.uk
Sat Feb 21 10:01:16 EST 2009
Ive been learning the C-API lately so I can write python extensions for some of my c++ stuff.
I want to use the new and delete operators for creating and destroying my objects.
The problem is python seems to break it into several stages. tp_new, tp_init and tp_alloc for creation and tp_del, tp_free and tp_dealloc for destruction. However c++ just has new which allocates and fully constructs the object and delete which destructs and deallocates the object.
Which of the python tp_* methods do I need to provide and what must they do to be compatible with python subclassing.
Also I want to be able to create the object directly in c++ eg "PyObject *obj = new MyExtensionObject(args);"
_________________________________________________________________
Love Hotmail? Check out the new services from Windows Live!
http://clk.atdmt.com/UKM/go/132630768/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090221/88048432/attachment.html>
More information about the Python-list
mailing list