Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66079
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.014 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'string': 0.09; 'repeated': 0.09; 'strings.': 0.09; 'subject:How': 0.10; 'cc:addr:python- list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'literals,': 0.16; 'literals.': 0.16; 'subject:python': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'module': 0.19; 'thu,': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; "i've": 0.25; 'script': 0.25; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'specifically': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; 'though.': 0.31; '(including': 0.33; 'equal': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'two': 0.37; 'checks': 0.38; 'fact': 0.38; 'does': 0.39; 'called': 0.40; 'most': 0.60; 'new': 0.61; 'simply': 0.61; 'simple': 0.61; 'determine': 0.67; 'subject:know': 0.84; 'that),': 0.91; 'to:none': 0.92 |
| 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:cc :content-type; bh=pzBRb0pu8lb3sr0cwdGdrlHZeBgJmaNN1ysRUBt/nIc=; b=khOwiu9ykKS6WTPHyqtSE1id0kzUgl6WcfH8NF5+y5lNMANXPNsC2cOl8FFSypsC4c rz9nsSoZ59mxdtEktotjh9IG90mUvHZABC4osKiGRtCBnwX3GBydrUGdNn4C675YRTxw 75nW4Bta8+YW7iF08eD9sUHgolcgZR7QFmbO/H3x/z8hq34/mjax4T7SyHUDSRKcb+WI dNU6bfs9LhHkp2S/xCZjL2HJTUkGraSvtaNOhiJwwJeIjt3MBud86qLV/WNL3jYYqZ12 5XUCVhTAlMm9E860LXiW3gFqcalxlQBKPERwjlBTMj0UTKr49eQWrjbIh/R3aBH+PEIP 8E9w== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.98.3 with SMTP id ee3mr53935808pbb.31.1392237221081; Wed, 12 Feb 2014 12:33:41 -0800 (PST) |
| In-Reply-To | <lFQKu.455927$cZ.440055@fx31.iad> |
| References | <lFQKu.455927$cZ.440055@fx31.iad> |
| Date | Thu, 13 Feb 2014 07:33:40 +1100 |
| Subject | Re: How does python know? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6779.1392237224.18130.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392237224 news.xs4all.nl 2924 [2001:888:2000:d::a6]:55944 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66079 |
Show key headers only | View raw
On Thu, Feb 13, 2014 at 7:17 AM, Tobiah <toby@tobiah.org> wrote: > This works for longer strings. Does python > compare a new string to every other string > I've made in order to determine whether it > needs to create a new object? No, it doesn't; but when you compile a module (including a simple script like that), Python checks for repeated literals. It's only good for literals, though. If you specifically need this behaviour, it's called 'interning'. You can ask Python to do this, or you can do it manually. But most of the time, you can just ignore id() and simply let two strings be equal based on their contents; the fact that constants are shared is a neat optimization, nothing more. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How does python know? Tobiah <toby@tobiah.org> - 2014-02-12 12:17 -0800
Re: How does python know? Tobiah <toby@tobiah.org> - 2014-02-12 12:27 -0800
Re: How does python know? Dave Angel <davea@davea.name> - 2014-02-12 16:59 -0500
Re: How does python know? Chris Angelico <rosuav@gmail.com> - 2014-02-13 07:33 +1100
Re: How does python know? Gary Herron <gary.herron@islandtraining.com> - 2014-02-12 13:02 -0800
Re: How does python know? Roy Smith <roy@panix.com> - 2014-02-12 20:54 -0500
csiph-web