[issue22444] Floor divide should return int

2015-10-02 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- resolution: -> rejected status: open -> closed ___ Python tracker ___

[issue22444] Floor divide should return int

2014-09-26 Thread Petr Viktorin
Changes by Petr Viktorin encu...@gmail.com: -- nosy: +encukou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___ ___ Python-bugs-list mailing

[issue22444] Floor divide should return int

2014-09-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: [Raymond] The current behavior has been around for a long time and is implemented in several modules including decimal and fractions. No, in the fractions module floor division returns an int: type(Fraction(2) // Fraction(1)) class 'int' It is also

[issue22444] Floor divide should return int

2014-09-22 Thread Mark Dickinson
Mark Dickinson added the comment: -1 from me, too. It's an unnecessary change, and the conversion from float to integer potentially expensive compared to the computation of the floating-point result (especially in extended floating-point implementations that allow a wider exponent range).

[issue22444] Floor divide should return int

2014-09-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: [Raymond] The PEP should be revised to say that floor division is defined to return a value that is *equal* to an Integral but not place any restriction on the return type. If we take this route, what float('inf') // 1 and float('nan') // 1 should

[issue22444] Floor divide should return int

2014-09-22 Thread Mark Dickinson
Mark Dickinson added the comment: If we take this route, what float('inf') // 1 and float('nan') // 1 should return? Probably exactly the same as they do right now. I think there's an argument that `float('inf') // 1` should have been `float('inf')`. But I'm not sure there's much of a

[issue22444] Floor divide should return int

2014-09-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Mark, Raymond suggested that The PEP 3141 should be revised to say that floor division is defined to return a value that is *equal* to an Integral. Since nan or inf are not *equal* to any Integral, the current implementation does not comply. In the

[issue22444] Floor divide should return int

2014-09-22 Thread Stefan Krah
Stefan Krah added the comment: Alexander Belopolsky rep...@bugs.python.org wrote: Raymond suggested that The PEP 3141 should be revised to say that floor division is defined to return a value that is *equal* to an Integral. I guess it should say equal to an Integral or a special value.

[issue22444] Floor divide should return int

2014-09-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: skrah I think both should return inf. What about this case: Decimal('1') // Decimal('-inf') Decimal('-0') 1. // float('-inf') -1.0 -- ___ Python tracker rep...@bugs.python.org

[issue22444] Floor divide should return int

2014-09-22 Thread Mark Dickinson
Mark Dickinson added the comment: I think that one's covered by #22198. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___ ___

[issue22444] Floor divide should return int

2014-09-21 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___

[issue22444] Floor divide should return int

2014-09-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: I think you're misreading the PEP. Floor division is defined to return a value *equal* to floor(x/y) but the type is unrestricted. That let's us correctly implement floor division for a variety of types including ints, floats, decimals, and fractions.

[issue22444] Floor divide should return int

2014-09-20 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- Removed message: http://bugs.python.org/msg227146 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___

[issue22444] Floor divide should return int

2014-09-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: Is this change compelling enough to break compatibility, or is it just a matter of purity? -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444

[issue22444] Floor divide should return int

2014-09-20 Thread Stefan Krah
Stefan Krah added the comment: Perhaps it's worth mentioning that several people on Python-ideas took the opposite view: math.floor() should return a float. PEP-3141 does not mention Infinities and NaNs: The Real ABC indicates that the value is on the real line, and supports the operations

[issue22444] Floor divide should return int

2014-09-20 Thread Stefan Krah
Stefan Krah added the comment: Argh, forget the second Haskell example: inf / 0 is fine. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___

[issue22444] Floor divide should return int

2014-09-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Is this change compelling enough to break compatibility, or is it just a matter of purity? According to the PEP 3141, Integer is a subtype of Real, so one should be able to substitute an Integer whenever Real is expected. The reverse is not true, for

[issue22444] Floor divide should return int

2014-09-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: However, Scheme returns floats Does Scheme's default integer type support arbitrarily large values? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444

[issue22444] Floor divide should return int

2014-09-20 Thread Case Van Horsen
Case Van Horsen added the comment: Does Scheme's default integer type support arbitrarily large values? Yes, at least is does on the version I tested. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444

[issue22444] Floor divide should return int

2014-09-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Perhaps it's worth mentioning that several people on Python-ideas took the opposite view: math.floor() should return a float. I sympathize with the idea that math module functions should return floats. I find it unfortunate that math.floor delegates

[issue22444] Floor divide should return int

2014-09-20 Thread Case Van Horsen
Case Van Horsen added the comment: What are the use-cases for float // float where integer result is not acceptable? It can lead to unexpected memory consumption when dealing with arbitrary precision values. What should Decimal('1e123456')//1 return? The result is exactly equal to

[issue22444] Floor divide should return int

2014-09-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: What should Decimal('1e123456')//1 return? I think Decimal case should be considered separately. Note that unlike float, they are not part of the numerical tower, so PEP 3141 arguments don't apply: isinstance(1.0, numbers.Real) True

[issue22444] Floor divide should return int

2014-09-20 Thread Case Van Horsen
Case Van Horsen added the comment: On Sat, Sep 20, 2014 at 9:38 AM, Alexander Belopolsky rep...@bugs.python.org wrote: Alexander Belopolsky added the comment: Perhaps it's worth mentioning that several people on Python-ideas took the opposite view: math.floor() should return a float. I

[issue22444] Floor divide should return int

2014-09-20 Thread Case Van Horsen
Case Van Horsen added the comment: What should Decimal('1e123456')//1 return? I think Decimal case should be considered separately. Note that unlike float, they are not part of the numerical tower, so PEP 3141 arguments don't apply: isinstance(1.0, numbers.Real) True

[issue22444] Floor divide should return int

2014-09-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: What are the use-cases for float // float where integer result is not acceptable? I can't think of any. I was mostly making the case for conservatism here. The indexing use case is interesting, although I suppose enumerate() should eliminate most instances

[issue22444] Floor divide should return int

2014-09-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Is this change compelling enough to break compatibility, or is it just a matter of purity? I agree with Antoine that making this change is a really bad idea. 1) The current behavior has been around for a long time and is implemented in several modules

[issue22444] Floor divide should return int

2014-09-20 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- nosy: +tim.peters ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___ ___

[issue22444] Floor divide should return int

2014-09-20 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- nosy: +alex ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___ ___

[issue22444] Floor divide should return int

2014-09-20 Thread Tim Peters
Tim Peters added the comment: Floor division on floats is an unattractive nuisance and should be removed, period - so there ;-) But short of that, I favor leaving it alone. Whose life would be improved by changing it to return an int? Not mine - and doing so anyway is bound to break

[issue22444] Floor divide should return int

2014-09-20 Thread Alex Gaynor
Alex Gaynor added the comment: I can't say that I've ever used // on floats, but it seems to me anyone doing so (as opposed to normal division + explicit rounding) *intentionally* might be broken by this change, but anyone doing this incidentally is not really in a gotcha situation. Since

[issue22444] Floor divide should return int

2014-09-19 Thread Alexander Belopolsky
New submission from Alexander Belopolsky: PEP 3141 defines floor division as floor(x/y) and specifies that floor() should return int type. Builtin float type has been made part of the PEP 3141 numerical tower, but floor division of two floats still results in a float. See also: * #1656 -

[issue22444] Floor divide should return int

2014-09-19 Thread Stefan Krah
Changes by Stefan Krah stefan-use...@bytereef.org: -- nosy: +skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___ ___ Python-bugs-list

[issue22444] Floor divide should return int

2014-09-19 Thread Case Van Horsen
Changes by Case Van Horsen cas...@gmail.com: -- nosy: +casevh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___ ___ Python-bugs-list mailing