Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102841
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Storing a big amount of path names |
| Date | Fri, 12 Feb 2016 14:49:15 +1100 |
| Lines | 25 |
| Message-ID | <mailman.66.1455248959.22075.python-list@python.org> (permalink) |
| References | <n9j94f$712$1@gioia.aioe.org> <56BD4DCD.4080401@mrabarnett.plus.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de HSxlaGVekskFrK2Zrt3AfwaFDWfwF73PjDl4q2RlGg4w== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'mrab': 0.05; 'sys': 0.05; 'cc:addr:python-list': 0.09; 'dict': 0.09; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'string,': 0.18; 'language': 0.19; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'simpler': 0.22; 'feb': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'equal': 0.34; 'received:google.com': 0.35; 'maps': 0.35; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; '12,': 0.37; 'received:209.85.213': 0.37; 'skip:9 10': 0.37; "won't": 0.38; 'received:209': 0.38; 'apart': 0.70; 'copies.': 0.72; 'you:': 0.79; 'chrisa': 0.84; 'to:none': 0.91 |
| 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=UwYkgtmn20oG1eV7rX2lO4bYcHHi8TsA0wvyCEbKDp8=; b=IILs9cr77BEcyeBNhqy21Plt5/R4gJhoILcbE5gPD0gYYtnp/2213Y5TFkS1FMoJpM qyTdkbNuULiViE9edYrZmBnwxCUaaBI4sZrWMYpdbhK6kH7HzGih5MrddfdwxPfkNke/ 5auvBk/FLnKBu3KWlnaHb2U571Ulg7Bxpc/XcVxamz6fzxE132rqrN8W4AaopvQtgJHn QqvKEQRBcBSkZdyVUfEXPJRLvJFgfIFbqC0wAe9FzdQLTht4+x72rj7VHzMjSW7GjyDT 7LpjxCSqcuYWbzg4/zqipsUV9Zyqo78c6xKXQhmAoJzx+HwUpBlXHIUkDKhf/lPkY//u SUmw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=UwYkgtmn20oG1eV7rX2lO4bYcHHi8TsA0wvyCEbKDp8=; b=b06P7k4neEQFiqtNCWqdRLBHaH01NWBmCtN5kRqPhxAyTUoZDqX2VrQL0MskHnuxEY vHzx/GyFqAMZIAaZJnrzbb6xkpxwPLOP6B6DWYtiRibgn/sJBJqlYQvhcXpVV+zBjNcF aWz0LmQyhemcGO0pSyknHBt45+jyi+3kIYofn4QzZ967K0Wn7bjJp8yb7aILpOCpMWUR JQLgo4iidhVrblBdDV/0Nd+DWhP5pKlR6P0B4UqO+5JP4FLfruynLE05vZAXBCiIMl+y L4WFX+InWegRi+2HaVv4oGRnbSm6CGU2Epk+227LSYJ6xw6uyeQvExiAq/FfDYbHos5Y zDCQ== |
| X-Gm-Message-State | AG10YOSPS/kkp8Tcpcxe8mvemxaVfvdFQR1QN5Hpp/k3SAAZNIsIo8JXHh4CxKGRAVmnJzlbj0o2PMbPA1dzJg== |
| X-Received | by 10.50.28.105 with SMTP id a9mr1724959igh.94.1455248956029; Thu, 11 Feb 2016 19:49:16 -0800 (PST) |
| In-Reply-To | <56BD4DCD.4080401@mrabarnett.plus.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| 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> |
| Xref | csiph.com comp.lang.python:102841 |
Show key headers only | View raw
On Fri, Feb 12, 2016 at 2:13 PM, MRAB <python@mrabarnett.plus.com> wrote:
> Apart from all of the other answers that have been given:
>
>>>> p1 = 'foo/bar'
>>>> p2 = 'foo/bar'
>>>> id(p1), id(p2)
> (982008930176, 982008930120)
>>>> d = {}
>>>> id(d.setdefault(p1, p1))
> 982008930176
>>>> id(d.setdefault(p2, p2))
> 982008930176
>
> The dict maps equal strings (dirnames) to the same string, so you won't have
> multiple copies.
Simpler to let the language do that for you:
>>> import sys
>>> p1 = sys.intern('foo/bar')
>>> p2 = sys.intern('foo/bar')
>>> id(p1), id(p2)
(139621017266528, 139621017266528)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Storing a big amount of path names Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2016-02-12 00:31 +0000
Re: Storing a big amount of path names Chris Angelico <rosuav@gmail.com> - 2016-02-12 11:39 +1100
Re: Storing a big amount of path names Ben Finney <ben+python@benfinney.id.au> - 2016-02-12 11:44 +1100
Re: Storing a big amount of path names Tim Chase <python.list@tim.thechases.com> - 2016-02-11 19:13 -0600
Re: Storing a big amount of path names Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-02-12 02:17 +0000
Re: Storing a big amount of path names MRAB <python@mrabarnett.plus.com> - 2016-02-12 03:13 +0000
Re: Storing a big amount of path names Chris Angelico <rosuav@gmail.com> - 2016-02-12 14:49 +1100
Re: Storing a big amount of path names Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2016-02-12 04:15 +0000
Re: Storing a big amount of path names Chris Angelico <rosuav@gmail.com> - 2016-02-12 15:23 +1100
Re: Storing a big amount of path names Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2016-02-12 04:45 +0000
Re: Storing a big amount of path names Chris Angelico <rosuav@gmail.com> - 2016-02-12 16:02 +1100
Re: Storing a big amount of path names Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2016-02-12 05:49 +0000
Re: Storing a big amount of path names Steven D'Aprano <steve@pearwood.info> - 2016-02-12 16:51 +1100
Re: Storing a big amount of path names Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-02-12 17:05 +0000
Re: Storing a big amount of path names Chris Angelico <rosuav@gmail.com> - 2016-02-13 04:18 +1100
Re: Storing a big amount of path names Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-02-12 21:37 +0000
Re: Storing a big amount of path names Ben Finney <ben+python@benfinney.id.au> - 2016-02-13 08:49 +1100
Re: Storing a big amount of path names Matt Wheeler <funkyhat@gmail.com> - 2016-02-12 23:31 +0000
Re: Storing a big amount of path names mkondrashin@gmail.com - 2016-02-13 12:19 -0800
Re: Storing a big amount of path names srinivas devaki <mr.eightnoteight@gmail.com> - 2016-02-12 11:46 +0530
csiph-web