Serhiy Storchaka added the comment:

> Serhiy, the performance of hash() for long strings isn't very relevant for 
> the general performance of a Python program.

It exposes the raw speed of hashing algorithm.  It is good as a first estimate, 
because more real cases require more sophisticated measurements.

> Short strings dominate. I've modified the timeit to create a new string 
> object every time.

timeit is absolutely not suitable for this.  Need to write a C program that 
uses the Python C API.

> for I in 5 10 15 20 30 40 50 60; do echo -ne "$I\t"; ./python -m timeit 
> -n100000 -r30 -s "h = hash; x = 'รค' * $I" -- "h(x + 'a')" | awk '{print $6}' 
> ; done

Please, do not be fooled by the wrong measurements. You measure the height of 
the building together with the hill, on which it stands. Use "-n1" and you will 
see a 
completely different numbers.


Python tracker <>
Python-bugs-list mailing list

Reply via email to