On Dec 7, 2009, at 12:17 PM, Dag Sverre Seljebotn wrote:

> I'm growing worried here. Will there be three levels of inference  
> (none,
> safe, full) exposed to end-users?
>
> That's way too complicated in my opinion. The point of "safe"  
> inference
> is that they can be done by default, without users having to know
> anything about it (except that some more code just run faster). If you
> have to actually read the manual to understand it and turn it on, you
> might as well use the full mode.

For debugging purposes, it might be good to make it easy to turn it  
completely off, especially since it's such a new feature. I do have to  
say I'm not a fan of the current interface. What I think would be more  
useful is

     cython.infer_types(True) # explicitly enable it everywhere.
     cython.infer_types(False) # explicitly disable it everywere,  
including "safe" inference.
     cython.infer_types(None) # the default, "safe" inference. What  
this actually means may change over time, but the semantics of the  
resulting code shouldn't.

This is similar to the dilemma with Profiling, where the default  
should probably be sometimes enabled (e.g. for def functions, not for  
inline functions) and a boolean value is an easy to remember explicit  
flag one can pass.

> I'm not against "bint" always being 0 or 1 in general though, so that
>
> cdef bint x = 3
>
> turns into
>
> cdef bint x = (3 != 0)
>
> and
>
> cdef extern bint foo()
> x = foo()
>
> turns into
>
> __pyx_v_x = (foo() != 0);

This may have performance ramifications...though probably small. Also,  
we can't make any guarantees (without extra work) about extern  
functions that are declared to return bint (which are not as uncommon  
as one would think...)

> But, it should be completely orthogonal to type inference!

Yep.

- Robert


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

Reply via email to