On Mon, Mar 6, 2017 at 2:03 PM, Elliot Gorokhovsky
<elliot.gorokhov...@gmail.com> wrote:
> On Sun, Mar 5, 2017 at 7:50 PM Chris Angelico <ros...@gmail.com> wrote:
>>
>>
>> I would be rather curious to know how frequently a list consists of
>> "numbers", but a mix of ints and floats. Does it happen a
>> lot in real-world code?
>>
>
> This is of course undecidable to verify statically, so we can't just crawl
> PyPI... however, I would argue that using mixed float-int lists is
> dangerous, and is more dangerous in Python 3 than in Python 2. So hopefully
> this is not very common. However, even if 10% (surely a vast overestimate)
> of sort calls are to mixed int-float lists, my patch would still yield a
> significant savings on average.

I agree that it's dangerous, but it is still common for programmers
and Python alike to treat 10 as functionally identical to 10.0 -
although as to being more dangerous in Py3, that's much of a muchness
(for instance, the single-slash division operator in Py2 can
potentially truncate, but in Py3 it's always going to give you a
float). But, fair point. I very much doubt it's as high as 10%, so
yeah, that would be advantageous.

Also, the performance hit is so small, and even that is in the very
worst case (a homogeneous list with one different type at the end). I
like changes that make stuff run faster.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to