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/071032.html below:

[Python-Dev] Interning string subtype instances

[Python-Dev] Interning string subtype instances"Martin v. Löwis" martin at v.loewis.de
Tue Feb 13 11:46:04 CET 2007
Greg Ewing schrieb:

> 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. 

No, it doesn't - see stringobject.c:string_richcompare.
If they are identical, they are quickly recognized as equal,
and as not not-equal. Otherwise, if eq comparison is requested,
it compares the size, then the first characters, then does
memcmp - so if they are unequal, it doesn't help that they
are both interned.

If comparison is for notequal, no special casing is performed
at all (except that knowing that identical strings aren't notequal).

The entire algorithm and optimization works just as fine for
a user-defined interning dictionary (assuming that all
relevant strings get into it).

Regards,
Martin
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