Python and STL efficiency
Fredrik Lundh
fredrik at pythonware.com
Tue Aug 22 17:15:27 EDT 2006
Maric Michaud wrote:
> The problem here, is that the strings in the set are compared by value, which
> is not optimal, and I guess python compare them by adress ("s*n is s*n" has
> the same complexity than "s*n == s*n" in CPython, right ?).
wrong.
> timeit -s"s='x'; n=1000" "s*n is n*s"
1000000 loops, best of 3: 1.9 usec per loop
> timeit -s"s='x'; n=1000" "s*n == n*s"
100000 loops, best of 3: 4.5 usec per loop
</F>
More information about the Python-list
mailing list