[Python-checkins] python/dist/src/Lib cgitb.py,1.4,1.5

Fredrik Lundh fredrik@pythonware.com
Thu, 27 Jun 2002 00:17:10 +0200


> ping@users.sourceforge.net wrote:
> > 
> > Update of /cvsroot/python/python/dist/src/Lib
> > 
> > Modified Files:
> >         cgitb.py
> 
> > +             if name[:1] == '_': continue
> 
> Any reason not to use:
> 
> if name.startswith('_'): continue
> 
> ?

tried benchmarking?

in CPython, startswith() is an improvement only if you don't
know the prefix length, or if you are too lazy to figure it out
and won't use the program much anyway...

and figuring out that "_" is exactly one character long isn't
that hard, really.

(can we please cut this python newspeak enforcement crap
now, btw.  even if slicing hadn't been much faster, there's
nothing wrong with using an idiom that has worked perfectly
fine for the last decade...)

</F>