In a message of Tue, 13 Oct 2015 08:38:07 -0700, Raymond Hettinger writes: > > >> On Oct 13, 2015, at 4:21 AM, Laura Creighton <l...@openend.se> wrote: >> >> Any chance of adding Decimal to the list of things that are also >> acceptable for things annotated float? > >>From Lib/numbers.py: > >## Notes on Decimal >## ---------------- >## Decimal has all of the methods specified by the Real abc, but it should >## not be registered as a Real because decimals do not interoperate with >## binary floats (i.e. Decimal('3.14') + 2.71828 is undefined). But, >## abstract reals are expected to interoperate (i.e. R1 + R2 should be >## expected to work if R1 and R2 are both Reals). > >That is still true: > >Python 3.5.0 (v3.5.0:374f501f4567, Sep 12 2015, 11:00:19) >[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin >Type "copyright", "credits" or "license()" for more information. >>>> from decimal import Decimal >>>> Decimal('3.14') + 2.71828 >Traceback (most recent call last): > File "<pyshell#1>", line 1, in <module> > Decimal('3.14') + 2.71828 >TypeError: unsupported operand type(s) for +: 'decimal.Decimal' and 'float' > > >Raymond Hettinger
I take it that is a 'no'. I merely worry about what hapens if people start relying upon the fact that a float annotation 'will handle all the numbers I care about' to the forgotten Decimal users such as myself. Laura _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com