"Jeffrey Yasskin" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

|        def __bool__(self):
|            """True if self != 0."""
|            return self != 0

Could this be a Number rather than Complex method?
---------------

| There is no built-in rational type

Floats constitute a bit-size bounded (like ints) set of rationals with 
denominators restricted to powers of two.  Decimal literals and Decimals 
constitute a memory bounded (like longs) set of rationals with denominators 
instead restricted to powers of ten.  I suspect that if both were presented 
as such, new programmers would be less likely to ask if
>>> 1.1
1.1000000000000001
is a bug in Python.

Math.frexp returns a disguised form of (numerator,denominator) (without 
common factor of two removal).  If undisguised functions were added (and 
the same for Decimal), there would be no need, really, for class Real.

If such were done, a .num_denom() method either supplementing or replacing 
.numerator() and .denominator() and returning (num, denom) would have the 
same efficiency justification of int.divmod.

I would like to see a conforming Rat.py class with unrestricted 
denominators.
--------------------

| And finally integers::
|
|    class Integral(Rational):
|        """Integral adds a conversion to int and the bit-string 
operations."""

The bit-string operations are not 'integer' operations.  Rather they are 
'integers represented as powers of two' operations.  While << and >> can be 
interpreted (and implemented) as * and //, the other four are genernally 
meaningless for other representations, such as prime factorization or 
fibonacci base.  The Lib Ref agrees:
   3.4.1 Bit-string Operations on Integer Types
   Plain and long integer types support additional operations that make 
sense
   only for bit-strings
Other integer types should not have to support them to call themselves 
Integral.  So I think at least |, ^, &, and ~ should be removed from 
Integral and put in a subclass thereof.  Possible names are Pow2Int or 
BitStringInt or BitIntegral.
-----------

In short, having read up to the beginning of Exact vs. Inexact Classes, my 
suggestion is to delete the unrealizable 'real' class and add an easily 
realizable non-bit-string integer class.

Terry Jan Reedy



_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to