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/070988.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
Mon Feb 12 21:29:37 CET 2007
Hrvoje Nikšic <hrvoje.niksic at avl.com> wrote:
> 
> I propose modifying PyString_InternInPlace to better cope with string
> subtype instances.

Any particular reason why the following won't work for you?

_interned = {}

def intern(st):
    #add optional type checking here
    if st not in _interned:
        _interned[st] = st
    return _interned[st]

If I remember the implementation of intern correctly, that's more or
less what happens under the covers.

 - 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