[Python-Dev] Python 2.3 release schedule

Oren Tirosh oren-py-d@hishome.net
Sat, 25 May 2002 13:21:19 -0400


On Sat, May 25, 2002 at 12:41:23PM -0400, Guido van Rossum wrote:
> OK, OK.
> 
> I timed pystone, and it's about 1.5% faster.  If that's the best we
> can do (and I think that any of the PEPs trying to optimize global and
> builtin access probably have about the same improvement rate as your
> code), I'm not sure we should worry about this.  I'd rather try to
> make method calls and instance attribute (both methods and instance
> variables) access faster...

pystone and other benchmarks spend their time in loops using fastlocals.  
I used to have a version where SHOW_DICTIONARY_STATS also counted fastlocals 
accesses for reference - they were 97% for pybench.

You're right that we need to find if this is really a problem for real-life
code. Are there any measurements for the speedup achieved in Zope by the 
argument/local tricks?

With a little more work this dictionary optimization should be applicable to 
attributes, too.  

> I wasn't worried about size; I was worried about correctness.  But it
> appears that your code is fine.

It isn't :-) I haven't implemented resizing of the hash table yet. If there 
is not enough room the negative entry isn't inserted. This bug is documented 
in my original posting.

> Hm, this reports:
> 0 inline dictionary lookups

It's a rebuild dependency problem. Make sure that ceval.c also gets 
recompiled after setting SHOW_DICTIONARY_STATS. When collecting stats the 
inline is not really inline. Sorry about that.

> Also note that your patch slows down fast access (by 3%)!  How can it?
> Adding more code to the interpreter's inner loop changes the cache
> behavior, etc.  Tim Peters can tell you more about this.

In my measurements there was no such slowdown. Is this consistent? 

Your cache behavior theory reminds me of an algorithm that was sped up by
almost 10% when a certain array type was changed from 64 to 67 entries.
For modern CPUs the common practice of using powers of two can cause cache 
thrashing.

	Oren