PEP 238 (revised)

Terry Reedy tjreedy at home.com
Fri Jul 27 00:21:50 EDT 2001


> PEP: 238

Generally agree with Eppstein's comments.


>This makes expressions expecting float or complex
>     results error-prone when integers are not expected but possible
as
>     inputs.

and vice versa for integer expressions getting float input


>     The problem is unique to dynamically typed languages: in a
>     statically typed language like C, the inputs, typically function
>     arguments, would be declared as double or float, and when a call
>     passes an integer argument, it is converted to double or float
at
>     the time of the call.  Python doesn't have argument type
>     declarations, so integer arguments can easily find their way
into
>     an expression.

Arguments that 'classic' division is bad for all languages obscured
this valid argument that it is particularly bad for Python.  Glad to
see it spelled out so nicely.


> Command Line Option
>...
>     warning (a DeprecatinWarning using the standard warning
framework)
Deprecation?


> Semantics of True Division
>
>     True division for ints and longs will convert the arguments to
>     float and then apply a float division.  That is, even 2/1 will
>     return a float (2.0), not an int.

Given that one spurious argument for this proposal was the claim that
float division preserves more information than quotient division, I
think it might be appropriate to warn here that the opposite is true
for sufficiently long longs, so that one may need to switch to
long//long to preserve accuracy.


>     - It has been proposed to call // the quotient operator.  I like
>       this.  I might rewrite the PEP to use this if enough people
like
>       it.  (But isn't the assumption that this truncates towards
>       zero?)

Its true that -8/3 = -(2+2/3), but I think divmod(-i,j)[0] is up for
grabs in most people's mental space.  This concern never entered my
mind until I read the above.

---
The only way I can think of to 'globally' turn on new division on my
own Windows computer is to rebind .py and .pyc to python.bat
containing '...python.exe -Dnew'.


Great revision!

Terry J. Reedy






More information about the Python-list mailing list