Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32710
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <oscar.j.benjamin@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.037 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; 'say,': 0.05; 'stops': 0.07; 'strings.': 0.07; 'cc:addr:python-list': 0.10; 'cases': 0.15; 'discussions': 0.15; '22:50,': 0.16; 'cc:name:python list': 0.16; 'for,': 0.16; 'intern': 0.16; 'unequal': 0.16; 'string': 0.17; 'wrote:': 0.17; 'char': 0.17; 'comparing': 0.17; 'code,': 0.18; 'cc:2**0': 0.23; "haven't": 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'bugs': 0.27; 'message- id:@mail.gmail.com': 0.27; 'chris': 0.28; 'comparison': 0.29; 'obscure': 0.29; "they'll": 0.29; 'though.': 0.29; 'unlikely': 0.29; 'source': 0.29; 'received:209.85.215.46': 0.30; 'subject: ?': 0.30; 'checked': 0.30; '(and': 0.32; 'url:python': 0.32; 'problem': 0.33; 'anyone': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'compared': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'url:org': 0.36; 'characters': 0.36; 'compare': 0.36; 'subject:with': 0.36; 'correctly': 0.37; 'two': 0.37; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'shows': 0.38; 'where': 0.40; 'header:Received:5': 0.40; 'end': 0.40; 'here': 0.65; 'identity.': 0.65; 'potentially': 0.66; 'heavy': 0.83; 'conclude': 0.84; 'confusing': 0.84; 'optimized,': 0.84; 'oscar': 0.84; 'url:cpython': 0.84; 'prone': 0.91; 'outcome': 0.93; 'imagine': 0.96 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=KwZyvnuEk/lEzMa0tCQQ33z3TImuXxstgWblH0tkL+M=; b=y4uJDm0tPMBCajBI42qXzrzTZ9NunjYakIvEe7Y4uDsAYa014L1Oh9hRmrMct7rtoM KGbrY7LEGqGtJr6/m1AAuyPSFSxr2H97KiSZdPy5vChJZsxTbvcQbFZdVSyrpBhxGp3q +DaeEegcdY/gTZ1SzbXcPjsMYq725PGwrLsXJZ2qhjcakMieihrA5ldqCN2fFnkZrjmn gP2bHYfyM3OosD5lLizezMa2glrk4V+22Aru85tmiErl+eVB5z/E9daNxVNMXMqC+YVE kvoV+e/FFOBjgq+WwnN+flLyCbnStYI2kTI7Bjx9TgiEadBlgmppfm+rW6YGMUNpyN+i WlCA== |
| MIME-Version | 1.0 |
| In-Reply-To | <CAPTjJmpCV4AZ9PGT6pMs2qzw4mm5F3Nb8ZstV4zD1Y++tgbe4g@mail.gmail.com> |
| References | <franck-9EED34.08303005092012@news.free.fr> <mailman.213.1346827305.27098.python-list@python.org> <franck-053A38.15194605092012@news.free.fr> <50475822$0$6867$e4fe514c@news2.news.xs4all.nl> <k73s18$5b4$1@panix5.panix.com> <50959154$0$6880$e4fe514c@news2.news.xs4all.nl> <50959827$0$29967$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmpCV4AZ9PGT6pMs2qzw4mm5F3Nb8ZstV4zD1Y++tgbe4g@mail.gmail.com> |
| Date | Sun, 4 Nov 2012 01:14:29 +0000 |
| Subject | Re: is implemented with id ? |
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
| To | Chris Angelico <rosuav@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | Python List <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3248.1351991672.27098.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1351991672 news.xs4all.nl 6917 [2001:888:2000:d::a6]:49735 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:32710 |
Show key headers only | View raw
On 3 November 2012 22:50, Chris Angelico <rosuav@gmail.com> wrote: > This one I haven't checked the source for, but ISTR discussions on > this list about comparison of two unequal interned strings not being > optimized, so they'll end up being compared char-for-char. Using 'is' > guarantees that the check stops with identity. This may or may not be > significant, and as you say, defending against an uninterned string > slipping through is potentially critical. The source is here (and it shows what you suggest): http://hg.python.org/cpython/file/6c639a1ff53d/Objects/unicodeobject.c#l6128 Comparing strings char for char is really not that big a deal though. This has been discussed before: you don't need to compare very many characters to conclude that strings are unequal (if I remember correctly you were part of that discussion). I can imagine cases where I might consider using intern on lots of strings to speed up comparisons but I would have to be involved in some seriously heavy and obscure string processing problem before I considered using 'is' to compare those interned strings. That is confusing to anyone who reads the code, prone to bugs and unlikely to achieve the desired outcome of speeding things up (noticeably). Oscar
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
is implemented with id ? Franck Ditter <franck@ditter.org> - 2012-09-05 08:30 +0200
Re: is implemented with id ? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-09-04 23:40 -0700
Re: is implemented with id ? Franck Ditter <franck@ditter.org> - 2012-09-05 15:19 +0200
Re: is implemented with id ? Hans Mulder <hansmu@xs4all.nl> - 2012-09-05 15:48 +0200
Re: is implemented with id ? aahz@pythoncraft.com (Aahz) - 2012-11-03 12:41 -0700
Re: is implemented with id ? Hans Mulder <hansmu@xs4all.nl> - 2012-11-03 22:49 +0100
Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-03 22:18 +0000
Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-11-04 09:50 +1100
Re: is implemented with id ? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-04 01:14 +0000
Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-04 03:10 +0000
Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-11-04 14:19 +1100
Re: is implemented with id ? aahz@pythoncraft.com (Aahz) - 2012-11-03 22:09 -0700
Re: is implemented with id ? Hans Mulder <hansmu@xs4all.nl> - 2012-11-04 11:13 +0100
Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-11-04 12:22 +1100
Re: is implemented with id ? aahz@pythoncraft.com (Aahz) - 2012-11-03 22:08 -0700
Re: is implemented with id ? Roy Smith <roy@panix.com> - 2012-11-03 18:41 -0400
Re: is implemented with id ? aahz@pythoncraft.com (Aahz) - 2012-11-03 22:12 -0700
Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 10:00 -0400
Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-05 14:41 +0000
Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 11:09 -0400
Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-05 15:36 +0000
Re: is implemented with id ? Hans Mulder <hansmu@xs4all.nl> - 2012-09-05 18:47 +0200
Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 13:19 -0400
Re: is implemented with id ? Terry Reedy <tjreedy@udel.edu> - 2012-09-05 14:31 -0400
Re: is implemented with id ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-05 22:08 -0400
Re: is implemented with id ? Duncan Booth <duncan.booth@invalid.invalid> - 2012-09-06 09:34 +0000
Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-09-06 19:50 +1000
Re: is implemented with id ? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-11-04 01:33 -0700
Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-05 09:14 +0000
Re: is implemented with id ? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-05 05:48 -0700
Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 09:46 -0400
Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-05 14:13 +0000
Re: is implemented with id ? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-05 11:08 -0600
Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-09-06 19:07 +1000
Re: is implemented with id ? Terry Reedy <tjreedy@udel.edu> - 2012-09-05 14:27 -0400
Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-06 06:44 +0000
Re: is implemented with id ? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-06 01:24 -0700
Re: is implemented with id ? Roy Smith <roy@panix.com> - 2012-09-06 08:16 -0400
Re: is implemented with id ? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-06 06:30 -0700
Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 14:40 -0400
csiph-web