[Python-3000] None in Comparisons
Guido van Rossum
guido at python.org
Wed Nov 12 20:19:47 CET 2008
On Tue, Nov 11, 2008 at 10:20 AM, Tim Peters <tim.peters at gmail.com> wrote:
> [M.-A. Lemburg]
>> That's fine. I'm just talking about the special case for None that
>> has existed in Python for years - and for a good reason.
> That's overstating it a bit ;-) In Python 1.5.1, comparisons were
> changed so that objects of numeric types compared smaller than objects
> of non-numeric types, and then 0 < None was true, not None < 0 (which
> became true substantially later). The reason for that change is
> explained in Misc/HISTORY (it was an attempt to preserve transitivity
> across chains of mixed-type comparisons).
> Later, during the move to rich comparisons, I was hacking the code in
> the same room with Guido, and realized something special had to be
> done with None.
> "Hey, Guido, what should we do about mixed-type comparisons against None?"
> "Hmm ... what do you think?"
> "Hmm ... OK, let's make None smaller than other types."
> "Oh, why not?"
> "Good enough -- but let's not document it -- it's an arbitrary
> implementation detail."
> "Of course!"
> In any case, we thought this was so arbitrary that we didn't hesitate
> to break that, up until that time, "0 < None" /had/ been true "for
> years - and for a good reason" ;-)
> not-all-good-reasons-are-particularly-good-ly y'rs - tim
Hah! I can vouch that this is pretty much how it went. It's a good
thing our process has changed a bit; in today's world this would have
required a PEP, and for good reason. I would have fought the proposal
if it had been proposed as a new feature for Python 3000.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000