I support PEP 326

Josiah Carlson jcarlson at nospam.uci.edu
Tue Jan 27 23:40:39 CET 2004

> I'm also in support of this PEP, and have cases in which I would use
> the new singletons.
> The biggest reason I believe the PEP should be accepted is that you
> simply *can't* "roll your own" in a heterogenous environment.  If I
> have my Min/Max objects and you have your Min/Max objects, someone's
> objects simply aren't going to work as expected.
> I'm in favor of Minimum and Maximum, though, if only for ease in
> discussing Python: the capital isn't obvious both verbally or at the
> beginning of a properly written sentence.

Unfortunately, I have a feeling that the PEP may be killed because there 
doesn't seem to be a location/name that is agreeable to those with 
voting power in python-dev.

A new module included into the standard library seems to be the easiest 
way to get it into Python.  However, considering that you cannot 
guarantee that the Max/Min will get their __cmp__ method called (when 
comparing against user-defined classes), you cannot guarantee the ordering.

If it were to get special treatment, by including it as a pseudo-builtin 
(always in Python, but doesn't have a name in __builtin__), it is a 5 
line modification to PyObject_Compare in object.c to guarantee the 
orderings with Max/Min:

That email also makes a case for min() and max() returning the minimum 
and maximum object respectively, whose string representations would be 
'min()' and 'max()' respectively.  It would result in the overloading of 
the min and max functions, but there is no general consensus in 
python-dev; some people like it due to its similarity to using int(), 
list(), dict(), float(), str(), long(), etc., but others (including 
Guido himself) think that min() and max() /should/ produce TypeErrors.

I'm thinking that maybe it should produce a warning for a release or two 
(that it used to produce a TypeError, unless 'from future import 
extremes' is at the beginning of a script), but in Python 2.5 or 2.6 
remove the warning.

Yeah.  If someone has a strong opinion either way, perhaps you should 
comment in python-dev.  If anyone has a better name/location suggestion, 
(that is not listed as an option in the current or previous versions in CVS:
), you suggestions are definitely appreciated.

Thank you,
  - Josiah

More information about the Python-list mailing list