A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-October/122237.html below:

[Python-Dev] Why not using the hash when comparing strings?

[Python-Dev] Why not using the hash when comparing strings? [Python-Dev] Why not using the hash when comparing strings?Benjamin Peterson benjamin at python.org
Fri Oct 19 14:56:42 CEST 2012
2012/10/19 Duncan Booth <duncan.booth at suttoncourtenay.org.uk>:
> Hrvoje Niksic <hrvoje.niksic at avl.com> wrote:
>
>> On 10/19/2012 03:22 AM, Benjamin Peterson wrote:
>>> It would be interesting to see how common it is for strings which have
>>> their hash computed to be compared.
>>
>> Since all identifier-like strings mentioned in Python are interned, and
>> therefore have had their hash computed, I would imagine comparing them
>> to be fairly common. After all, strings are often used as makeshift
>> enums in Python.
>>
>> On the flip side, those strings are typically small, so a measurable
>> overall speed improvement brought by such a change seems unlikely.
>
> I'm pretty sure it would result in a small slowdown.

Dictionary code has its own special path for string comparisons, so
this is not an issue.



-- 
Regards,
Benjamin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4