Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102843
| 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 15:23:20 +1100 |
| Lines | 39 |
| Message-ID | <mailman.67.1455251003.22075.python-list@python.org> (permalink) |
| References | <n9j94f$712$1@gioia.aioe.org> <56BD4DCD.4080401@mrabarnett.plus.com> <mailman.66.1455248959.22075.python-list@python.org> <n9jm9n$m77$1@gioia.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | news.uni-berlin.de VVZ6qjBVAZxgAmopTtjAcQAKGaKK1+pciyf4cvWGaxMA== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'memory.': 0.05; 'mrab': 0.05; 'sys': 0.05; 'correct.': 0.07; 'cc:addr:python-list': 0.09; '__init__': 0.09; 'arg': 0.09; 'dirname': 0.09; ':-)': 0.12; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'paulo': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'string': 0.17; 'language': 0.19; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'fix': 0.21; 'simpler': 0.22; 'feb': 0.23; 'references': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'chris': 0.26; 'coding': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'strings,': 0.29; 'character': 0.29; 'skip:s 30': 0.31; 'class': 0.33; 'equal': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; '12,': 0.37; 'things': 0.38; 'received:209': 0.38; 'means': 0.39; "didn't": 0.39; 'takes': 0.39; 'your': 0.60; 'back': 0.62; '>>>>>': 0.66; 'apart': 0.70; 'million': 0.74; 'obvious': 0.76; '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:content-transfer-encoding; bh=metySYucfdpKzi7DZ1HYFgYH+Qu6iHf9RoT0R6ltx+U=; b=d3S6Xw34Z+4pQuAmp06vvmWUMsBiB0+R2K97VO9hdy7znYOo9FK4jp28tj9LeDnXtX BLaev6L3Hb0Cci/lX1k7N6O2PLY13kXPW61Kp/bYB+IPDg0cH0vsaWKxk3gZWKZzVSpf kAUbZWswwvGylDDHMNZle640M6j5QC8lXD6Zym1cnJ0Ay4panWzsvBseh/qphlqOkKPe G9fTgA+hYNbPYhwVOiC20NGRisheyF0776/t2a+yTDr+X5KeKiHY7l00K6XL+xFVxFhl MXe2XvKZOayenPIgbW0bdhOT97Iih7dLUhcNJaYuUL5zytrdrAeN0qDzVLSWsloTtw+E xfIA== |
| 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:content-transfer-encoding; bh=metySYucfdpKzi7DZ1HYFgYH+Qu6iHf9RoT0R6ltx+U=; b=V+ESieHNp/uSxIYH49+x6SevFLWdWrreQG5wWvJjks4x5PHsGEyUVqKkQIuyofLioY L4IS5R3PWOGrN8iUAJ2XSoYvLFF3StkSjVQ6gUEQVeetlrNRhhGchN+eTcSHFuqqpu6l lhQFRfuf4G9zbTlfdOYXOowc2a8cP4xOSmzy7CKYUNFEE6UBxvlwOvp0tYi5LVR4giNU wh1xHbPOHergC3po79C+TzjHvNKLQE1zhR5PG75lp+1fuQrgeycre+KDYi4vUC24Rs+2 D5D9YzW5+lrFExppQP1IEOoAI3K+FedUw7XqkyuDcipLa21XHGkWtWNYjuv2sg3I6tI8 Wk0A== |
| X-Gm-Message-State | AG10YOQy5Fr0uTI+KWnY2uwub2LRMPTTjE3Hmkh1pjtvUIo+9fec/vgGVNJiXFNgdGAnvK+rwlxcNAQhAKPbwA== |
| X-Received | by 10.107.132.90 with SMTP id g87mr579017iod.157.1455251000678; Thu, 11 Feb 2016 20:23:20 -0800 (PST) |
| In-Reply-To | <n9jm9n$m77$1@gioia.aioe.org> |
| 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:102843 |
Show key headers only | View raw
On Fri, Feb 12, 2016 at 3:15 PM, Paulo da Silva
<p_s_d_a_s_i_l_v_a_ns@netcabo.pt> wrote:
> Às 03:49 de 12-02-2016, Chris Angelico escreveu:
>> 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:
>>>
> ...
>>
>> 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)
>>
>
> I didn't know about id or sys.intern :-)
> I need to look at them ...
>
> As I can understand I can do in MyFile class
>
> self.dirname=sys.intern(dirname) # dirname passed as arg to the __init__
>
> and the character string doesn't get repeated.
> Is this correct?
Correct. Two equal strings, passed to sys.intern(), will come back as
identical strings, which means they use the same memory. You can have
a million references to the same string and it takes up no additional
memory.
But I reiterate: Don't even bother with this unless you know your
program is running short of memory. Start by coding things in the
simple and obvious way, and then fix problems only when you see them.
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