[Python-checkins] CVS: python/dist/src/Python ceval.c,2.287,2.288

M.-A. Lemburg mal@lemburg.com
Wed, 07 Nov 2001 21:22:27 +0100


Jeremy Hylton wrote:
> 
> >>>>> "MAL" == M -A Lemburg <lemburg@users.sourceforge.net> writes:
> 
>   MAL> Update of /cvsroot/python/python/dist/src/Python In directory
>   MAL> usw-pr-cvs1:/tmp/cvs-serv19062/Python
> 
>   MAL> Modified Files:
>   MAL>  ceval.c
>   MAL> Log Message: Add fast-path for comparing interned (true) string
>   MAL> objects.
> 
>   MAL> This patch boosts performance for comparing identical string
>   MAL> object by some 20% on my machine while not causing any
>   MAL> noticable slow-down for other operations (according to tests
>   MAL> done with pybench).
> 
> Hey!  Don't do that.
> 
> The last time this came up, I thought there was a pretty clear
> conclusion that we did not want to make thise change. 

Huh ?

> The tests done
> with pybench are empirical observations, but they don't disprove the
> theory that this change does slowdown comparisons of other objects.

AFAIR, there was consent over this and the tests I did using pybench
showed that there in fact is no noticable slowdown which was to
be expected from theory: If you look at the code, you'll see that 
only identical objects trigger the fast path -- that's one pointer 
compare plus a conditional jump; not a whole lot if you track 
down the paths all other objects have to take through the rich 
compare logic.

As for using pybench to determine the impact: I am pretty
confident that the results shown by pybench can be mapped
to many different applications out there. It tests a wide
variety of different corners in the Python interpreter, so
slow-downs and performance gains can be easily noticed and
tracked down.

It's certainly a lot better than relying on pystone or timing
regression suites.

> The last discussion we had on this subject was this message:
> 
> ---------------------------------------------------------------
> 
> From: "Tim Peters" <tim.one@home.com>
> To: <python-dev@python.org>
> Subject: RE: [Python-Dev] Slices and "==" optimization
> Date: Thu, 1 Nov 2001 02:42:39 -0500
> 
> Before we special-case strings more, we should fix what we've got:  Martin
> (IIRC) inserted a fast path at the start of do_richcmp early in the 2.2
> cycle:
> 
> ---------------------------------------------------------------
> 
> Did anyone try to fix what we already have?  I'd like to see what the
> effect of that is.

Tim already checked in patches for this, so I figured it was time
to look into the fast path patch which I did today.

If you want to look at the pybench test output, I can post that 
too.

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