On Tue, Sep 15, 2009 at 3:19 AM, Stefan Behnel <[email protected]> wrote:
>
>>>
>>> 1) When calling foo(a), we could emit a compile-time warning and
>>> generate C code with runtime type-check... What's the point of duck
>>> typing here iff foo() actually requires a tuple?
>>
>> We don't want to generate so many warnings they become useless, I
>> personally wouldn't want that on by default. It's nice because a lot
>> of the inputs, return results, etc. are not typed, e.g. I can do foo
>> (bar(x)) where bar is any old Python function.
>
> -1 on "untyped" warnings. We still /discourage/ explicit typing in most cases.
>

But the current status is far from optimal... cdef functions do not do
internally any typecheck on typed arguments (for performance
reasons?), then you can call it with anything, and you can easily
end-up with a segfault...

I understand that we /discourage/ explicit typing and agree with that.
However, I think that if a user INSIST in using explicit typing for
some args in a cdef function, she should be prepared to make sure that
when calling that function, the argument have a proper, known type at
Cython compile-time... In fact, this is a way to discourage even more
explicit typing... And this will help catch nasty bugs when explicit
typing is used.

In short, I think that moving/enforcing type-checks from
Python-runtime to Cython-compile-time is a very good deal... Far
better to get a complain from Cython, before you release your code,
than a nasty, embarrassing Python exception when end-users try your
code... I know, unittesting should catch these problems, but
honestly... how many codes out there have 100% code coverage?

Final note: cdef functions with no argument typecheck at all are as
dangerous as Fortran 77... IMHO, Cython should do better, just because
Python/Cython users are not real programmers ;-) ...


-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to