[Python-3000] PEP 31XX: A Type Hierarchy for Numbers (and other algebraic entities)

Baptiste Carvello baptiste13 at altern.org
Sun Apr 29 00:01:17 CEST 2007


Bill Janssen a écrit :
>> Jeffrey, is there any way you can drop the top of the tree and going
>> straight from Number to Complex -> Real -> Rational -> Integer? These
>> are the things that everyone with high school math will know.
> 
> I think knowledge of the concepts of group, ring, and field is
> supposed to be standard knowledge for any high-school senior -- isn't
> this what the "new math" was all about?.  But they're pretty
> fundamental to computer science; anyone trying to do serious work in
> the field (that is, anyone with a reason to read the PEP) should have
> a nodding acquaintance with them.
> 
> Bill
> 
Even knowing the maths, you still have 2 problems:

1) the number types in Python are pretty much defined by the way CPUs work, not
by the math (Decimal beeing the exception), which causes some conceptual
impedance mismatch. Discussing to what extend floating point numbers can be
compared to theoritical real numbers is a can of worms we probably don't want to
open :-)

2) In the PEP, the concepts are used *inconsistently*. Complex derives from Ring
because the set of complex numbers *is a* ring. Int derives from Complex because
integer are complex numbers (or, alternatively, the set of integers *is included
in* the set of complex numbers). The consistent way could be to make the Complex
class an instance of Ring, not a subclass.

Cheers,
BC



More information about the Python-3000 mailing list