Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; '(especially': 0.07; 'bytes.': 0.07; 'received:verizon.net': 0.07; 'subject:missing': 0.07; 'terry': 0.07; 'python': 0.08; 'builtin': 0.09; 'intern': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'api': 0.09; 'mon,': 0.15; 'devs': 0.16; 'fiddle': 0.16; 'functions),': 0.16; 'reedy': 0.16; 'subject:String': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'header:In- Reply-To:1': 0.22; 'url:dev': 0.23; 'pm,': 0.26; 'generally': 0.30; 'str': 0.30; 'chris': 0.30; 'subject:?': 0.30; 'url:library': 0.30; 'minor': 0.32; 'does': 0.32; "can't": 0.32; 'done': 0.33; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.33; 'header:X-Complaints-To:1': 0.34; 'something': 0.35; 'url:python': 0.36; 'optimization': 0.36; 'but': 0.37; 'received:org': 0.37; 'think': 0.38; 'should': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'either': 0.39; '(with': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'url:3': 0.66; 'url:0': 0.67; 'attention': 0.71; 'concept': 0.74; '(bytes)': 0.84; 'eponymous': 0.84; 'subject:moved': 0.84; '3.3': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: String interning in Python 3 - missing or moved? Date: Mon, 23 Jan 2012 23:18:39 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1327378738 news.xs4all.nl 6905 [2001:888:2000:d::a6]:58435 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19312 On 1/23/2012 9:25 PM, Chris Rebert wrote: > On Mon, Jan 23, 2012 at 4:38 PM, Chris Angelico wrote: >> Python 2 can intern 'str' (bytes) strings (with the eponymous builtin, >> and with C API functions), though not unicode. Python 3 does not have >> that builtin, nor the C API; I can't find any support for either str >> or bytes. >> >> Has it been moved, or is interning as a concept deprecated? > > The former, into `sys`: > http://docs.python.org/dev/library/sys.html#sys.intern > Search the "What's New"s in the future. > http://docs.python.org/release/3.1.3/whatsnew/3.0.html#builtins I think that the devs decided that interning is a minor internal optimization that users generally should not fiddle with (especially how that so much is done automatically anyway*), while having it a builtin made it look like something they should pay attention to. *I am not sure but what hashes for strings either are or in 3.3 will always be cached. -- Terry Jan Reedy