[ python-Bugs-1060644 ] Remove .min() and .max() from Decimal

SourceForge.net noreply at sourceforge.net
Fri Nov 5 06:18:54 CET 2004

Bugs item #1060644, was opened at 2004-11-04 20:44
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 

Category: Python Library
Group: Python 2.4
>Status: Closed
>Resolution: Invalid
Priority: 6
Submitted By: Facundo Batista (facundobatista)
Assigned to: Raymond Hettinger (rhettinger)
Summary: Remove .min() and .max() from Decimal

Initial Comment:

I propose to remove them as explicit methods because
the same behaviour can be achieved with the builtin

>>> Decimal("NaN").max(Decimal(8))
>>> max(Decimal("NaN"), Decimal(8))

(in the docs you put that .max() should return NaN if
either is a NaN, but it's not showing that behaviour
(and couldn't find any docs where says that it must to)).

I'm assigning this to you to have your opinion, but if
you're ok I can do the cleaning (code and docs).

I'm putting this as priority 6 because it will be more
painless to take them away before 2.4 final.


.    Facundo


>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-11-05 00:18

Logged In: YES 

'nuff said.


Comment By: Tim Peters (tim_one)
Date: 2004-11-04 22:27

Logged In: YES 

min() and max() are defined operations in the IBM spec, and 
have to work the way the spec says they work.  Here's a 
reference for max:


Python's builtin min() and max() don't meet those 
requirements.  In particular, if the result is numeric it must be 
rounded according to current context settings (the same as 
applying the spec's unary plus).

Note that our docs are wrong if they say max returns NaN if 
either input is a NaN.  The spec says (for max):

    If either operand is a NaN then the general rules apply,
    unless one is a quiet NaN and the other is numeric, in
    which case the numeric operand is returned.

I note that it says the same for min, so it's an odd sort of 

The implemented max seems correct:

>>> from decimal import Decimal as d
>>> eight = d("8")
>>> nan = d("NaN")

>>> nan.max(eight)
>>> eight.max(nan)

The builtin max() isn't even consistent here, giving a different 
result depending on the order in which the operands are 

>>> max(eight, nan)
>>> max(nan, eight)


You can respond by visiting: 

More information about the Python-bugs-list mailing list