[Python-ideas] Fwd: Make `float('inf') //1 == float('inf')`

Petr Viktorin encukou at gmail.com
Thu Sep 18 19:32:25 CEST 2014


On Thu, Sep 18, 2014 at 7:04 PM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
>
> On Thu, Sep 18, 2014 at 12:17 PM, Steven D'Aprano <steve at pearwood.info>
> wrote:
>>
>> > What I do care about is that Python and Numpy should give the same
>> > result. It would be nice to see this changed in either Python or
>> > Numpy, whatever the "correct" result is.
>>
>> That is reasonable.
>
>
> Consistency with NumPy cannot aways be achieved.  Note that numpy.floor
> returns floats while math.floor returns ints.  (NumPy cannot follow stdlib
> here because it does not have arbitrary precision integers.)

Right. That particular difference has a reason behind it, however.
There is no reason to differ here, except perhaps backwards
compatibility.

And if backwards compatibility is the reason for Python not changing,
it should be documented (as an unfortunate mistake) so other
implementations do the same thing. And it should have a test (which
I'm happy to write once a decision is reached -- wanting to write a
test for floor floatdiv is largely why I'm here debating this).


More information about the Python-ideas mailing list