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

Fred L. Drake, Jr. fdrake@acm.org
Tue, 30 Oct 2001 13:05:11 -0500


Martin v. Loewis writes:
 > into the code. In an application that almost exclusively does
 > COMPARE_OPs on identical strings, I got a 30% speed-up. OTOH, this
 > same code caused a 10% slowdown if I converted the "==" into "<>".

  It's very questionable whether we'll find an optimization that works
well for any serious variety of applications.  Perhaps there's some
way to build up a lookup table of fast paths, and have the slow path
try that first, but I'm sceptical.

 > Running the PyXML test suite, I counted 120000 cases where
 > slow_compare was done, and only 700 cases identical strings were
 > compared for equality.

  I wouldn't expect XML applications to gain from such an
optimization, since many compares will involve Unicode objects, either
to each other or to 8-bit strings.


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation