mark florisson, 21.05.2013 15:32:
> On 21 May 2013 14:14, Vitja Makarov wrote:
>>
>> def foo(int N):
>>     x = 1
>>     y = 0
>>     for i in range(N):
>>         x = x * 0.1 + y * 0.2
>>         y = x * 0.3 + y * 0.4
>>     print typeof(x), typeof(y)
>>
>> Here both x and y will be inferred as double
> 
> Ok, so I assume it promotes the incoming types (all reaching
> definitions)? If N == 0, then when using objects you get an int,
> otherwise a double.

I'm not sure what you mean here. I certainly don't think the inferred type
of x and y should depend on the value of N. It should always be a double,
because that's the spanning type for all paths. In the very unlikely case
that that's not what the user wants, explicit typing will easily fix it for
them.

Stefan

_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to