On Dec 7, 2009, at 11:28 AM, Stefan Behnel wrote:

> Robert Bradshaw, 03.12.2009 18:10:
>> Nice. With that, I can't see any place that inference of doubles
>> wouldn't be safe either, and it would be very convenient.
>
> I have an implementation, but I noticed that typing the lhs of  
> assignments
> isn't enough to support code like this:
>
>   x = 2.5 + 1.5 ** float(some_obj) # could be string/float/...
>
> because the calculation would still run in Python space, although we  
> know
> it could run completely in C after unpacking the last operand. So I  
> needed
> to force Python float operands into C doubles inside of  
> NumBinopNode, in
> addition to the support in the type inference mechanism.

I'm not sure where exactly where the float(...) becoming a double  
operation optimization occurs, but perhaps it might be easier to  
simply modify the call node to infer the type of float(...) as being a  
double.

> Would that still be enabled by the type inference switch? I guess a
> separate option would be better, right?

Well, that's controlled by the float() optimization, right? (I guess  
there's not a switch for that.)

- Robert

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

Reply via email to