[Cython] Typing of Python objects?
Martin C. Martin
martin at martincmartin.com
Wed Jan 30 16:53:20 CET 2008
Thanks a lot for Pyrex and Cython. They're going to save us a ton of
work in speeding up the performance critical parts of our app.
Are there any plans to add typing and type inference to Python objects
in Cython? For example, it would be great if the following function
could call PyDict_SetItemString:
cdef foo(char *string, mydict):
mydict[string] = 5
Of course, we'd need some way to indicate that mydict is a dict.
WingIDE uses this:
cdef foo(char *string, mydict):
isinstance(mydict, dict)
mydict[string] = 5
But in a pinch, this would do:
cdef foo(char *string, mydict):
if isinstance(mydict, dict):
mydict[string] = 5
Or
cdef foo(char *string, mydict):
assert isinstance(mydict, dict)
mydict[string] = 5
For now, I guess I need to do a cdef extern and call
PyDict_SetItemString explicitly?
Thanks a lot,
Martin
More information about the Cython-dev
mailing list