On 2 June 2013 07:22, Stefan Behnel <stefan...@behnel.de> wrote: > 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.
Right, my point is that taking the spanning type of all paths is different from python semantics. But if you can prove something about the value of N (e.g. N <= 0, or N > 0), you should certainly exploit this information. > Stefan > > _______________________________________________ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel