Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26864

Re: [newbie] A question about lists and strings

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'cpython': 0.05; 'objects,': 0.07; 'subject:question': 0.08; 'alter': 0.09; 'etc).': 0.09; 'flags,': 0.09; 'modulo': 0.09; 'objects.': 0.09; 'to)': 0.09; 'aug': 0.13; 'also:': 0.16; 'constants': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ids.': 0.16; 'least,': 0.16; 'time).': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'appears': 0.18; '(or': 0.18; 'subject:] ': 0.19; 'fairly': 0.21; 'received:209.85.214.174': 0.21; 'occurs': 0.22; 'header:In-Reply-To:1': 0.25; 'compiled': 0.27; 'scale': 0.27; 'module.': 0.27; 'message- id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'fri,': 0.30; 'point': 0.31; 'subject:lists': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'possible': 0.37; 'two': 0.37; 'received:209': 0.37; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'course.': 0.62; 'different': 0.63; 'more': 0.63; 'potentially': 0.66; 'believe': 0.69; 'etc,': 0.84; 'factors,': 0.84; 'angel': 0.93
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 :content-type; bh=6FtERTjGyEL0Hx0hRGimv/PA8eA/nBoC++eoOlTQ0vs=; b=WUympqE5RtZhzR177voTS1seqZWeXaJu3DqmUmWgEM8p2Rit3odQTO/VakQe7ancbx vi+sUTKh/ueIuUnBUtWXRC3AcjkryNc12URI/vJHiRupzrp5Rmh1Is5OONRW5dtJ/xDb 3UTi16BOfVepxdcJZ2A5N2qt7y0+eCn0GEaQRxSLJeYsGRvmjipiHFVWVXO9fcMEWFnk A4CEhEiIIlJHhb+ICyjYrVT1A5dI/6kjU0eV7cUveoxYUt2ACidK251m7mwXd5fL7/SH v7KU5P2WhFvofvroCQ3ypWFITMedrVUPKTfdTn3GNuKO+Emvf9P7WlZuBF4MTj2xOHGQ Pszw==
MIME-Version 1.0
In-Reply-To <5024E8CC.9020703@davea.name>
References <k02jn0$id2$1@news.albasani.net> <39A401F0-12DD-464F-A0D1-639C56FA48A0@gmail.com> <mailman.3148.1344592099.4697.python-list@python.org> <k02mpk$p0e$1@news.albasani.net> <CAPTjJmrabsW3w8WNqDNeGU8f5rc0Kq0U83Vd7To7sX-SOWWtew@mail.gmail.com> <5024E8CC.9020703@davea.name>
Date Fri, 10 Aug 2012 21:00:40 +1000
Subject Re: [newbie] A question about lists and strings
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.3158.1344596443.4697.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1344596444 news.xs4all.nl 6932 [2001:888:2000:d::a6]:47844
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26864

Show key headers only | View raw


On Fri, Aug 10, 2012 at 8:56 PM, Dave Angel <d@davea.name> wrote:
>> On Fri, Aug 10, 2012 at 8:07 PM, Dave Angel <d@davea.name> wrote:
>>> But if you said  c=651 and d=651, you'd have two
>>> objects, and the two names would be bound to different objects, with
>>> different ids.
>> To be more accurate, you *may* have two different objects. It's
>> possible for things to be optimized (eg with small numbers, or with
>> constants compiled at the same time).
>
> You're right, of course.  But I picked the value of 650+ deliberately,
> as I believe CPython doesn't currently optimize ints over 256.

Yep. Also:

>>> a=651; b=651
>>> a is b
True
>>> a=651
>>> a is b
False

Same thing occurs (or at least, appears to) with constants in the same
module. Could potentially be a fairly hefty optimization, if you use
the same numbers all the time (bit flags, scale factors, modulo
divisors, etc, etc, etc).

Still doesn't alter your fundamental point of course.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 11:19 +0200
  Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 13:28 +0400
  Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 13:48 +0400
    Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:12 +0200
      Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 20:37 +1000
      Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:37 -0400
      Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 14:56 +0400
        Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 13:08 +0200
      Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:56 -0400
      Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 21:00 +1000
      Re: [newbie] A question about lists and strings Roman Vashkevich <vashkevichrb@gmail.com> - 2012-08-10 15:06 +0400
  Re: [newbie] A question about lists and strings Peter Otten <__peter__@web.de> - 2012-08-10 11:59 +0200
    Re: [newbie] A question about lists and strings Rotwang <sg552@hotmail.co.uk> - 2012-08-10 16:12 +0100
  Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:07 -0400
    Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:31 +0200
      Re: [newbie] A question about lists and strings Chris Angelico <rosuav@gmail.com> - 2012-08-10 20:40 +1000
        Re: [newbie] A question about lists and strings Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-08-10 12:48 +0200
          Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:58 -0400
      Re: [newbie] A question about lists and strings Dave Angel <d@davea.name> - 2012-08-10 06:53 -0400

csiph-web