Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26864
| References | (1 earlier) <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 | 2012-08-10 21:00 +1000 |
| Subject | Re: [newbie] A question about lists and strings |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3158.1344596443.4697.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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