[Python-Dev] Slices and "==" optimization
Guido van Rossum
guido@python.org
Tue, 30 Oct 2001 09:00:13 -0500
> As with all micro-optimizations, the win usually only shows
> up in some applications. The one I'm writing uses lot's of
>
> if tagtype == 'starttag':
> if tagtype == 'endtag':
> ...
>
> Since the 'starttag' and 'endtag' strings are interned and
> I'm also interning the strings which are stored in tagtype,
> I'd like to benefit from the fact that the compare will actually
> work as 'is'-compare. However, I don't want to use 'is' because
> I consider interning only an optimization and not a feature
> of the language.
Agreed.
> That's why I would like the simple
>
> if (v == w) return 0;
>
> integrated into the ceval loop right along the INT-compare
> optimization.
Maybe this could be done as follows:
if (v == w && PyString_CheckExact(v)) return 0;
> This may also help in some other situations where objects are
> shared.
Now *that* is the speculation for which Tim will chop off your
head. :-)
--Guido van Rossum (home page: http://www.python.org/~guido/)