Lisandro Dalcin wrote:
> On Tue, Sep 15, 2009 at 7:09 PM, Robert Bradshaw
> <[email protected]> wrote:
>
>> This is one thing that cython -a is good for, it lets you easily spot
>> cases where unnecessarily type checking, etc. is performed.
>>
>>
>
> No, Robert. Let's see: mpi4py has 7 K lines of Python code. This
> generates 82 K lines (x12) of C code... I really do not have the time
> to review all that output.
>
> Anyway, let's stop here... Perhaps some day I'll convince you about
> adding a "-pedantic" option to Cython :-) ... But now we have more
> important things to work on...
>
I'm sorry, I need to post this, then I'll stop. I understand you better
now and think it's been useful; and like you I don't consider cython -a
the final solution here.
Myself I think that the bar for compiler directives which people find
useful (and which default to off) should be very low, so I'm not opposed.
But what about this instead: A directive to warn/give error on any
undeclared variables? I.e.:
@cython.warning_undeclared(True)
def foo():
cdef object a
cdef int b
a = b = c = 3 # warns that "c" is not declared and auto-typed to object
This would also help me when I forget to type the variables of a loop in
a function I'm speeding up. And I think this would also catch the case
you described and help avoid unecesarry type-checking?
Both Visual Basic and Fortran have this BTW (respectively "Option
Explicit" and "implicit none"). Not that I consider any of those
pinnacles of good language design :-) But I think this could be a useful
directive to have for those who want to use it.
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev