[Python-Dev] PEP 326 (quick location possibility)

Tim Peters tim.one at comcast.net
Thu Jan 29 13:49:52 EST 2004


[Skip]
> Perhaps a stupid observation, but empty lists, dicts, strings and
> tuples appear to compare larger than any int or float:

Why do you presume it's numbers that are getting compared in a min/max
search loop?  Sometimes it's tuples, sometimes lists, sometimes strings,
sometimes instances of a user-defined class (etc).

> ...
> I realize this is implementation-dependent (and I'm sure Tim already
> knows all this stuff).  People wanting absolute min and max objects
> could use something like the above to generate such stuff when needed.

Sorry, they can't.  If so happens that every string compares less than every
tuple -- you really expect sensible code to be written that way?  The
brittleness compounds if you try.  Extending that example, it so happens
that every Unicode string compares *larger* than every tuple, so apart from
the inherent obscurity of relying on accidental crap like that, it can break
when your input data changes a little.




More information about the Python-Dev mailing list