On Wed, Nov 5, 2008 at 2:52 PM, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Ondrej Certik wrote:
>> one drawback is that I still need to use .pxd files to
>> declare cdef functions. Example:
>>
>> @cython.locals(n=cython.int)
>> def fact(n):
>>     ...
>>
>> in order for this to become a "cdef int foo()" function, I need to
>> have this line in foo.pxd:
>>
>> cdef int fact(int n)
>>
>> (And then the @cython decorator is not necessary). I'd like to have
>> everything in the .py file. Could that be approached by for example
>> something like:
>>
>> @cython.locals(n=cython.int, _return=cython.int, cdef=True)
>> def fact(n):
>>     ...
>
> That would block calling a local variable "cdef", which would be valid
> Python. Calling it _cdef might solve this, but having "_return" blocked
> already is bad enough.
>
> How about a generic decorator @cython.cdef ?
>
>    @cython.cdef
>    @cython.locals(n=cython.int, _return=cython.int)
>    def fact(n):
>        ...
>
> would become
>
>    cdef int fact(int n):
>        ...

Yes, that looks perfectly ok. And the same for extension classes.

Ondrej
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to