[Pyrex] classes and callbacks

Test Drive testdrive6 at gmail.com
Sun Oct 8 07:41:11 UTC 2006


Hi Greg,

I was wrapping a C code in pyrex. While wrapping it, I made it OO as well.
However, I face one problem with this design ie callbacks. For every
instance of the class i need to track which class registered which callback
function. I do this currently by using global dict with instance id as the
key. This serves the purpose. However, i thought that probably by giving a
special treatment to callbacks (specially in classes), I will get  cleaner
and better code.  As well I think it is worth including in pyrex. If you
think it is worth it, It will be great if you guyz can pull this off.

class ABC:
      cdef class_callback unsigned long mycb_func(int a, int b):
                 return a*b

In the above code, I have not specified self for mycb_func,  as specifying
self or anything else will change the callback function signatures. if
mycb_func is automatically registered as a member function for the class ABC
(by virtue of class_callback kyword), without specifying self, it would be
awesome. It would be possible to have per instance registered callbacks
without using a global dict to track  and find these.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20061008/435308e8/attachment.html 


More information about the Pyrex mailing list