[issue26680] Incorporating float.is_integer into Decimal

2020-10-08 Thread Robert Smallshire
Robert Smallshire added the comment: Yes Raymond, I can prepare a new PR as soon as the faulty PR has been rolled back. -- ___ Python tracker <https://bugs.python.org/issue26

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2020-10-06 Thread Robert Smallshire
Robert Smallshire added the comment: First, I would like to apologise for the confusion I have inadvertently caused. I didn't see Raymond's question and Guido's clear response here about not modifying the numeric tower, as it came _long_ after activity had moved to GitHub, and code had been

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2019-08-22 Thread Robert Smallshire
Robert Smallshire added the comment: > * no forward movement for a year and half For most of that year and a half my pull-request was sitting in Github <https://github.com/python/cpython/pull/6121> awaiting review by two core devs, of which you Raymond, were one. I don't like

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2018-03-15 Thread Robert Smallshire
Robert Smallshire <r...@sixty-north.com> added the comment: Serhiy, you asked for use cases, not uses. The former can exist without the latter. Use cases for is_integer() include all existing uses of x == int(x), or other less obvious means of detecting integer values. Folks try

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2018-03-15 Thread Robert Smallshire
Robert Smallshire <r...@sixty-north.com> added the comment: Python in effect contains an example itself. The math.factorial(x) function contains what is in-effect an is_integer() check as a guard. -- ___ Python tracker <rep...@bugs.p

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2018-03-15 Thread Robert Smallshire
Change by Robert Smallshire <r...@sixty-north.com>: -- pull_requests: +5885 stage: needs patch -> patch review ___ Python tracker <rep...@bugs.python.org> <https://bugs.pyt

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2018-03-12 Thread Robert Smallshire
Robert Smallshire <r...@sixty-north.com> added the comment: Thank you Raymond. I'll work up a PR shortly. -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2018-03-12 Thread Robert Smallshire
Robert Smallshire <r...@sixty-north.com> added the comment: Apologies for the email splurge. That's the first and last time I'll use the email interface to bugs.python.org. -- ___ Python tracker <rep...@bugs.python.org> <https://

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2018-03-12 Thread Robert Smallshire
Robert Smallshire <r...@sixty-north.com> added the comment: To respond to Raymond's points: 1) Nobody is suggesting that every float method should also be available on int. Clearly some methods on float are not applicable to int. 2) Taken narrowly, you're right that is_integer() does n

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2018-03-10 Thread Robert Smallshire
Robert Smallshire <r...@sixty-north.com> added the comment: I've recently run into this issue impeding duck-typing between int and float again, when used in conjunction the int.__pow__, which may variously return an int or float depending on the value - not the type - of the arg

[issue26701] Documentation for int constructor mentions __int__ but not __trunc__

2016-04-06 Thread Robert Smallshire
New submission from Robert Smallshire: The documentation for the int(x) constructor explains that if possible, it delegates to x.__int__(). The documentation does not explain that there is a fallback to x.__trunc__() if x.__int__() is not available. The only mention of __trunc__

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2016-04-05 Thread Robert Smallshire
Robert Smallshire added the comment: Thanks Stefan for the illuminating example. I knew I shouldn't have strayed off-topic. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2016-04-05 Thread Robert Smallshire
Robert Smallshire added the comment: >> Were float to inherit from Rational, rather than Real ... > This would break the Liskov substitution principle. How so? Rational extends Real with only numerator, denominator and __float__. Isn't the existence of float.as_integer_ratio demo

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2016-04-05 Thread Robert Smallshire
Robert Smallshire added the comment: Java makes no claim to have a numeric tower. Amongst the dynamic languages I surveyed Matlab (isinteger), Javascript ES6 (isInteger), PHP (is_integer), R (is.integer), TCL (is entier), and as we have seen Scheme (integer?) all have methods for testing

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2016-04-04 Thread Robert Smallshire
Robert Smallshire added the comment: To be clear, I'm not arguing that is_integer is in the same category as hex and fromhex; is_integer is a mathematical property of the number, whereas hex and from hex are representational. Nobody expects interoperability of string representations

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2016-04-01 Thread Robert Smallshire
Robert Smallshire added the comment: As for whether the shortcut float.is_integer(x) was needed, it has different behavior to x==int(x) when x is either NaN or an infinity. We must even deal with two different exception types OverflowError or ValueError respectively for these two values

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2016-03-31 Thread Robert Smallshire
Robert Smallshire added the comment: Adding the second patch file. -- Added file: http://bugs.python.org/file42336/is_integer_decimal.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue26680] Incorporating float.is_integer into the numeric tower and Decimal

2016-03-31 Thread Robert Smallshire
New submission from Robert Smallshire: When the useful float.is_integer method was added the opportunity was missed to incorporate this method into the numeric tower defined in numbers.py. This increased the API distance between different number types, making them less substitutable than

[issue26663] asyncio _UnixWritePipeTransport._close abandons unflushed writes

2016-03-29 Thread Robert Smallshire
Changes by Robert Smallshire <robert.smallsh...@gmail.com>: -- type: -> behavior ___ Python tracker <rep...@bugs.python.org> <http://bugs.pyt

[issue26663] asyncio _UnixWritePipeTransport._close abandons unflushed writes

2016-03-29 Thread Robert Smallshire
New submission from Robert Smallshire: Note: This report is based on a close reading of the asyncio code, rather than having experienced defective behaviour in test or production. The documentation for BaseTransport.close() states: "Close the transport. If the transport has a b