[Python-Dev] Slices and "==" optimization

M.-A. Lemburg mal@lemburg.com
Wed, 31 Oct 2001 09:08:26 +0100


Tim Peters wrote:
> 
> >> Running the PyXML test suite, I counted 120000 cases where
> >> slow_compare was done, and only 700 cases identical strings were
> >> compared for equality.
> 
> > As Fred mentioned, this is probably due to the fact that
> > Unicode objects are not interned. Neither are typical
> > XML tag names; could make a difference... don't know.
> 
> Whatever it's due to, it means the fast-path code cost extra cycles in the
> 119300 (of 120000) cases it didn't pay off.  If it costs F extra cycles when
> it fails, and saves S cycles when it succeeds, the question for this test is
> whether 119300*F < 700*S.  S has to about about 170X larger than F for a net
> win in this case, else there's a net loss.

I'd be interested in the overall performance change in the PyXML
test suite run. If you look at the code that gets executed for
the checking the fast path criteria down in slow_compare, then
your equation doesn't look that bad anymore.

I'll run pybench on this and post the results here.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/