Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'subject:Python': 0.05; 'happily': 0.07; 'subject:missing': 0.07; 'python': 0.08; 'intern': 0.09; 'am,': 0.12; 'cc:addr:python-list': 0.15; 'randomize': 0.16; 'subject:String': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'cheers,': 0.20; 'memory': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'stefan': 0.24; 'cc:2**0': 0.25; 'received:209.85.220': 0.27; 'message-id:@mail.gmail.com': 0.28; '24,': 0.28; 'explicitly': 0.28; 'cc:addr:python.org': 0.29; 'hash': 0.30; 'solved': 0.30; 'chris': 0.30; 'subject:?': 0.30; 'quite': 0.31; 'tue,': 0.32; 'it.': 0.33; 'anything': 0.34; 'it."': 0.34; 'reference': 0.37; "there's": 0.37; 'received:google.com': 0.37; 'used,': 0.38; 'received:209.85': 0.38; 'first.': 0.38; 'received:209': 0.39; 'subject:: ': 0.39; 'data': 0.40; 'worth': 0.61; 'your': 0.61; 'provided': 0.61; 'same,': 0.67; 'benefit': 0.68; '(based': 0.84; '12:17': 0.84; 'sender:addr:chris': 0.84; 'subject:moved': 0.84; 'attacks': 0.93; 'presumably': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc :x-gm-message-state:content-type; bh=o+MXwR1kvbtr531ET1kO5PfR6SE79lnRPzcmxMZ29mc=; b=ABuw5Gv0WisdrnfC3cMzHMhkeRPTzhtr1jQcSXZ1L3k/nKAqT2HC6u196anPX83f7S UPRhvxDFv4C3NqhOVpFEWrozdN1LuQJ3wWE9hbJs7xcEhZ740YZ9Sb7Fg3vzAJ9pQ0/m jIoXoF8Fx//LP6snEqhbHBUge5BHgLT5BMEBc= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Tue, 24 Jan 2012 00:33:48 -0800 X-Google-Sender-Auth: RBK383ihJDkVwQuBDdtdNbLqkao Subject: Re: String interning in Python 3 - missing or moved? From: Chris Rebert To: Stefan Behnel X-Gm-Message-State: ALoCoQm98vH51DP0anvcOTuQm+nbttadSEP4G0xJ0oMQUnW3dKKZkhjzeYwTEHdlT719eh7KiIzV Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1327394031 news.xs4all.nl 6936 [2001:888:2000:d::a6]:54141 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19332 On Tue, Jan 24, 2012 at 12:17 AM, Stefan Behnel wrote: > Chris Angelico, 24.01.2012 05:47: >> Lua and Pike both quite happily solved hash collision attacks in their >> interning of strings by randomizing the hash used, because there's no >> way to rely on it. Presumably (based on the intern() docs) Python can >> do the same, if you explicitly intern your strings first. Is it worth >> recommending that people do this with anything that is >> client-provided, and then simply randomize the intern() hash? > > If you want to encourage them to fill up their memory with user provided > data in a non-erasable way, Actually, quoth intern()'s docs: "Interned strings are not immortal; you must keep a reference to the return value of intern() around to benefit from it." Cheers, Chris