[Python-Dev] insertdict slower?

M.-A. Lemburg mal@lemburg.com
Sat, 03 Feb 2001 14:47:20 +0100


Tim Peters wrote:
> 
> [Tim]
> > ... to the contrary, it said lookdict got 4.5% *faster* in 2.1.
> 
> Ack, I was reading the wrong column.  It actually said that lookdict went
> from 0.48 to 0.49 seconds, while insertdict went from 0.20 to 0.26.
> 
> http://mail.python.org/pipermail/python-dev/2001-February/012428.html
> 
> Whatever, the profile isn't pointing at things that make sense, and is
> pointing at things that don't.
> 
> Then again, why anyone would believe any output from a computer program is
> beyond me <wink>.

Looks like Jeremy's machine has a problem or this is the result
of different compiler optimizations. On my machine using the same
compiler and optimization settings I get the following figure for
DictCreation (2.1a1 vs. 2.0):

                  DictCreation:    1869.35 ms   12.46 us   +8.77%

That's below noise level (+/-10%).
 
> needs-sleep-ly y'rs  - tim
> 
> PS:  Sorry to say it, but rich comparisons have nothing to do with this
> either!  Run your dict creation test under a debugger and watch it -- the
> rich compares never get called.  The basic reason is that hash(i) == i for
> all Python ints i (except for -1, but you're not using that).  So the hash
> codes in your dict creation test are never equal.  But there's never a
> reason to call a "real compare" unless you hit a case where the hash codes
> *are* equal.  The latter never happens, so neither does the former.  The
> insert either finds an empty slot at once (& so returns immediately), or
> collides.  But in the latter case, as soon as it sees that ep->me_hash !=
> hash, it just moves on the next slot in the probe sequence; and so until it
> does find an empty slot.

Hmm, seemed like a natural explanation from looking at the code.
So now we have two different explanations for a non-existing
problem ;-)

I'll rerun the benchmark for 2.1a2 and let you know of the 
findings.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/