[Pyrex] python callback appended to external C struct

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Dec 5 01:12:49 CET 2005


Lenard Lindstrom wrote:
> I was curious myself if anyone knew of a safe way to go from a Python 
> object to void pointer and back in Pyrex.

Casting it to void * is okay as long as you keep a
reference to it somewhere for as long as it will be
needed.

> Why not use a module level 
> dictionary instead that maps object instances by object id.

That will work, you just need to keep in mind that the
function object will then live forever unless you have
some way of explicitly removing it.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+



More information about the Pyrex mailing list