[Cython] Another type idea
Robert Bradshaw
robertwb at math.washington.edu
Mon Mar 10 23:55:48 CET 2008
On Mar 10, 2008, at 3:26 PM, Dag Sverre Seljebotn wrote:
> Getting ideas after posting...
>
> One could also declare known return type of existing ptyhon lib
> functions like this:
>
> assumetype(cython.types.int, sum)
>
> def foo(arr):
> s = sum(arr)
> # s is now native C int
>
> leading to eliminating all the casts.
I'm not so sure about this--overriding the declared types of builtin
functions, the non-locality of the declaration (assumetype could be
anywhere in the file, or imported from somewhere else, but the
conversion happens inside the function).
- Robert
More information about the Cython-dev
mailing list