[Python-checkins] CVS: python/nondist/peps pep-0239.txt,1.5,1.6
Guido van Rossum
gvanrossum@users.sourceforge.net
Wed, 08 Aug 2001 08:36:43 -0700
Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv8456
Modified Files:
pep-0239.txt
Log Message:
Add nice summary by Marcin 'Qrczak' Kowalczyk from c.l.py for and
against unifying ints and rats.
Index: pep-0239.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0239.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** pep-0239.txt 2001/07/29 09:49:26 1.5
--- pep-0239.txt 2001/08/08 15:36:41 1.6
***************
*** 72,75 ****
--- 72,106 ----
For rational numbers with integer values?
+ - Marcin 'Qrczak' Kowalczyk summarized the arguments for and
+ against unifying ints with rationals nicely on c.l.py:
+
+ Arguments for unifying ints with rationals:
+
+ - Since 2 == 2/1 and maybe str(2/1) == '2', it reduces surprises
+ where objects seem equal but behave differently.
+
+ - / can be freely used for integer division when I *know* that
+ there is no remainder (if I am wrong and there is a remainder,
+ there will probably be some exception later).
+
+ Arguments against:
+
+ - When I use the result of / as a sequence index, it's usually
+ an error which should not be hidden by making the program
+ working for some data, since it will break for other data.
+
+ - (this assumes that after unification int and rational would be
+ different types:) Types should rarely depend on values. It's
+ easier to reason when the type of a variable is known: I know
+ how I can use it. I can determine that something is an int and
+ expect that other objects used in this place will be ints too.
+
+ - (this assumes the same type for them:) Int is a good type in
+ itself, not to be mixed with rationals. The fact that
+ something is an integer should be expressible as a statement
+ about its type. Many operations require ints and don't accept
+ rationals. It's natural to think about them as about different
+ types.
+
References