[issue43602] Include Decimal's in numbers.Real

2021-04-22 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: Well, probably everyone else agree with Raymond. Yet, I'll try to clarify few things. On Mon, Apr 19, 2021 at 03:38:29AM +, Raymond Hettinger wrote: > No strong use cases have emerged that would warrant overturning > the long-standing prior decisions

[issue43602] Include Decimal's in numbers.Real

2021-04-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: Considering Oscar's response, Mark's comments, and prior discussions, we should close this. No strong use cases have emerged that would warrant overturning the long-standing prior decisions on this topic. -- resolution: -> rejected stage: -> re

[issue43602] Include Decimal's in numbers.Real

2021-04-16 Thread Oscar Benjamin
Oscar Benjamin added the comment: I've never found numbers.Real/Complex to be useful. The purpose of the ABCs should be that they enable you to write code that works for instances of any subclass but in practice writing good floating point code requires knowing something e.g. the base, preci

[issue43602] Include Decimal's in numbers.Real

2021-04-16 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: Probably, this thread https://mail.python.org/archives/list/python-id...@python.org/thread/KOE3MQ5NSMGTLIH6IHAQWTIOELXG4AFQ/ is relevant here. I would appreciate Oscar's feedback on this issue. -- nosy: +oscarbenjamin

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +tim.peters ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: On Tue, Mar 23, 2021 at 01:03:47PM +, Mark Dickinson wrote: > What do you think the result of `1.0 + Decimal(1)` should be, and > more importantly why? Possible options are: > > - Decimal('2') > - 2.0 (a float) > - a `TypeError` (as now) > - some kind

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Mark Dickinson
Mark Dickinson added the comment: > Seems so, for a static typing. But Python is a dynamically typed > language, isn't? I think we're talking at cross purposes. Static and dynamic typing have nothing to do with this. What do you think the result of `1.0 + Decimal(1)` should be, and more im

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: On Tue, Mar 23, 2021 at 10:21:50AM +, Mark Dickinson wrote: > Mark Dickinson added the comment: > > I assume, the reason is: there is no lossless conversion to float's (and > > vice verse). > and in fact we _do_ have lossless conversion of floats to D

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Mark Dickinson
Mark Dickinson added the comment: > I assume, the reason is: there is no lossless conversion to float's (and vice > verse). No, I don't think that's the reason (and in fact we _do_ have lossless conversion of floats to Decimal instances). IMO, the reasons are: - it's not obvious what the *t

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Sergey B Kirpichev
Sergey B Kirpichev added the comment: > Operations between decimals and floats raise a TypeError. I saw this) And as I said, I assume, the reason is: there is no lossless conversion to float's (and vice verse). If so (point 2), neither multiple-precision type (e.g. gmpy2.mpfr) can subclass

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Raymond Hettinger
Change by Raymond Hettinger : -- Removed message: https://bugs.python.org/msg389373 ___ Python tracker ___ ___ Python-bugs-list mail

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: We don't have a choice here. Operations between decimals and floats raise a TypeError. So, we can't register Decimal as a Real; otherwise, static type checking wouldn't be able to flag the following as invalid: def add(a: Real, b: Real) -> Real:

[issue43602] Include Decimal's in numbers.Real

2021-03-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: We don't have a choice here. Operations between decimals and floats raise a TypeError. So, we can't register Decimal as a Real; otherwise, static type checking wouldn't be able to flag the following as invalid: def add(a: Real, b: Real) -> Real:

[issue43602] Include Decimal's in numbers.Real

2021-03-22 Thread Sergey B Kirpichev
New submission from Sergey B Kirpichev : Commit 82417ca9b2 includes Decimal's in the numbers tower, but only as an implementation of the abstract numbers.Number. The mentioned reason is "Decimals are not interoperable with floats" (see comments in the numbers.py as well), i.e. there is no lo