On Aug 19, 2009, at 1:25 AM, Stefan Behnel wrote:
> Robert Bradshaw wrote:
>> However, I'm not following how decorating these functions makes
>> everything slower. Sure, it's a bit slower on the first import, but
>> the decorator is no re-called on each import. Clearly I'm missing
>> something here, could you explain why the decorator is being
>> repeatedly called?
>
> It shouldn't, at least for Cython 0.11 code (without inner functions).
> Decorators are evaluated at import time, so as long as the module
> isn't
> unloaded (which doesn't really work for extension modules in Py2
> anyway),
> they are evaluated only once, and when compiled, the Cython
> builtins are
> actually evaluated at compile time.
>
>
>> Also, if you want to have cdef
>> classes, especially across various modules, you'll have to do that
>> anyways right now. (Patches for fixing this, e.g. via class
>> decorators, would be highly appreciated).
>
> Given that Cython supports class decorators (ok, not in a release
> version,
> but that will obviously change one day ;), I think the main
> obstacle here
> is that Py2 doesn't support them, so there's not that much to gain
> from
> using them in pure Python mode - unless you specifically target
> Cython and
> Py3.x only.
I believe that 2.6 has them as well, but it is still a limited
audience. No reason not to support it though...
Perhaps we could also support
cdef class A:
a = cython.declare(int)
(FYI, this is an alternative to the @cython.locals, but of course in
a function would get run every time.)
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev