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/2007-February/071119.html below:

[Python-Dev] Interning string subtype instances

[Python-Dev] Interning string subtype instances [Python-Dev] Interning string subtype instancesJosiah Carlson jcarlson at uci.edu
Wed Feb 14 20:16:28 CET 2007
Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 
> Josiah Carlson wrote:
> > def intern(st):
> >     ...
> > 
> > If I remember the implementation of intern correctly, that's more or
> > less what happens under the covers.
> 
> That doesn't quite give you everything that real interning
> does, though. The string comparison method knows when both
> strings are interned, so it can compare them quickly
> whether they are equal or not. Your version could detect
> equal strings quickly, but not unequal strings.

Assuming that dictionaries and the hash algorithm for strings is not
hopelessly broken, I believe that one discovers quite quickly when two
strings are not equal.  Simple testing seems to confirm this, but I
didn't work too hard to disprove it either.

 - Josiah

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