True, False, None (was re. Pruss's manifesto)

Alex Martelli aleax at aleax.it
Mon Nov 10 08:41:59 EST 2003


KefX wrote:
   ...
> As for the rest of your suggestions, well, from what I've heard, half of
> the issues have been beaten to death, and some of the rest seem silly. Why
> make "True" a keyword when it's fine as it is?

True, False and None may well become keywords in the future, because that
might make things "even finer" in some respects.  E.g., right now,
    while True:
        ...
has to look-up 'True' at EACH step just in case the ... code rebinds
that name.  This _is_ a bit silly, when there is no real use-case for
"letting True be re-bound".  Nothing major, but...:

[alex at lancelot test]$ timeit.py -c -s'import itertools as it' 'c=it.count()'
'while True:' '  if c.next()>99: break'
10000 loops, best of 3: 91 usec per loop

[alex at lancelot test]$ timeit.py -c -s'import itertools as it' 'c=it.count()'
'while 1:' '  if c.next()>99: break'
10000 loops, best of 3: 76 usec per loop

...it still seems silly to slow things down by 20% w/o good reason...

(people who wonder why suddenly some Pythonistas are _so_ interested in
efficiency might want to review
http://www.artima.com/weblogs/viewpost.jsp?thread=7589
for a possible hint...).

OTOH, the chance that the spelling of True, False and None will change
is close to that of a snowball in the _upper_ reaches of Hell (the
_lower_ ones are in fact frozen, as any reader of Alighieri well knows,
so the common idiom just doesn't apply...:-).


Alex





More information about the Python-list mailing list