On Sun, Oct 21, 2012 at 3:06 PM, Devin Jeanpierre <jeanpierr...@gmail.com> wrote: > On Sat, Oct 20, 2012 at 10:57 PM, Nick Coghlan <ncogh...@gmail.com> wrote: >> PEP 3141 is indeed the driver for these changes, and it's based on the >> Python 3.x numeric tower consisting of strict supersets: Complex > >> Real > Rational > Integral > > Pedant mode: That numeric tower is wrong as it applies to Python -- we > have some rational types that can represent some numbers that can't be > represented by our complex and """real""" types. > > >>> int(float(10**100)) == 10**100 > False > > (Also, floats aren't reals and no computer can store any number that > is not rational and we should stop pretending they can. (Complex > numbers get a free pass because "complex numbers with rational real > and imaginary parts" is not a memorable name for a type.))
Floats are not rational either, since they allow infinities and NaN as values. Both float and Decimal are approximations to the Real number set, as int and Fraction are approximations to the Integer and Rational sets. In all cases, they cannot express the full scope of the associated numeric concept, because they're limited by their physical representations as bit patterns inside the computer (while that limit is technically available memory for the unbounded representations, the practical limit is lower than that if you want vaguely reasonable running times for arbitrary arithmetic operations). As far as the conversion operators go, I don't recall there being any discussion one way or the other - the question simply never came up, presumably because all code tested already returned complex objects from __complex__. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com