Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69818
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3a.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.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'cpython': 0.05; 'cc:addr :python-list': 0.11; 'python': 0.11; 'assume': 0.14; '(1,': 0.16; '(note': 0.16; '3.0)': 0.16; 'elements).': 0.16; 'elements,': 0.16; 'equal.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'immutability': 0.16; 'implies': 0.16; 'mutability': 0.16; 'objects.': 0.16; 'other,': 0.16; 'tuples,': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'seems': 0.21; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'paul': 0.24; 'cc:2**0': 0.24; '2010,': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '>>>>': 0.31; 'apparently': 0.31; 'tuples': 0.31; 'another': 0.32; "can't": 0.35; 'definition': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'sure': 0.39; 'even': 0.60; 'more': 0.64; 'subject:good': 0.84; '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:content-transfer-encoding; bh=Hx7zkTnePDmjr05syRx+bl/irW5P/AT0FCXEuK0Lez0=; b=FFdpuTKdQYDfvUgA4RZz5vcAI/JR5Gq/DbXh0uIlTuPq3vByLQZMT/x8Md0matFnSP 3HR/LfYd5yM/p2296bpDleDafVsRZI7l7Y2PeXcw4UWse8AIIgHrZmjR74lSp16Mre99 jzNn5xqwpSK8taPuWG5qZVWdBHe9QE48PiS5eDSJQ8BChxyr0bgIuh5oL3zykiJSMhBx +iI22ss+JJpLY3UlSXvn0el0oQraMHWE3SivltYBol9y6xd4lLqkg9QMcq3QmdDFqBzu jNl6ZNkjRVppv4CZojX4Eqqf1AjXlSiX7TSHyeyKN0teuZMGx+Xr5m5XCWbzDUatd25M Be9w== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.181.70 with SMTP id du6mr31302833pac.23.1396885452353; Mon, 07 Apr 2014 08:44:12 -0700 (PDT) |
| In-Reply-To | <5342C3AD.9080707@subsignal.org> |
| References | <89df32f9-c8ae-4b7b-bfc4-01c574aabcae@googlegroups.com> <53410185.6050304@islandtraining.com> <5342C3AD.9080707@subsignal.org> |
| Date | Tue, 8 Apr 2014 01:44:12 +1000 |
| Subject | Re: Mutable objects inside tuples - good or bad? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| 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.8983.1396885455.18130.python-list@python.org> (permalink) |
| Lines | 34 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1396885455 news.xs4all.nl 2929 [2001:888:2000:d::a6]:39154 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:69818 |
Show key headers only | View raw
On Tue, Apr 8, 2014 at 1:26 AM, Paul Kölle <pkoelle@gmail.com> wrote: > It seems a tuple's immutability is debatable, or is this another instance of > the small-integer-reuse-implementation-detail-artifact? > > Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) > [GCC 4.4.5] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. >>>> a = ([1,2],[3,4]) >>>> b = a >>>> a is b > True >>>> a == b > True >>>> c = (1,2,3) >>>> d = (1,2,3) >>>> c is d > False >>>> c == d > True That's nothing to do with mutability or reuse. With a and b, you assigned one to be the same as the other, so they are by definition identical (and equal; tuples assume that identity implies equality, even though that may not be true of their elements). With c and d, you assigned separate tuples, so they're allowed to be separate objects. I'm not sure if they're allowed to be constant-folded, but CPython apparently isn't doing so. They are still equal, though; they contain equal elements, ergo they are equal. (Note that (1, 2, 3) and (1.0, 2.0, 3.0) are equal, but they obviously can't be identical any more than "1 is 1.0" can ever be True.) ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Mutable objects inside tuples - good or bad? John Ladasky <john_ladasky@sbcglobal.net> - 2014-04-05 23:53 -0700
Re: Mutable objects inside tuples - good or bad? Gary Herron <gary.herron@islandtraining.com> - 2014-04-06 00:25 -0700
Re: Mutable objects inside tuples - good or bad? Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-04-06 00:55 -0700
Re: Mutable objects inside tuples - good or bad? Rustom Mody <rustompmody@gmail.com> - 2014-04-06 08:07 -0700
Re: Mutable objects inside tuples - good or bad? Chris Angelico <rosuav@gmail.com> - 2014-04-06 18:25 +1000
Re: Mutable objects inside tuples - good or bad? Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-04-06 04:01 -0700
Re: Mutable objects inside tuples - good or bad? Paul Kölle <paul@subsignal.org> - 2014-04-07 17:26 +0200
Re: Mutable objects inside tuples - good or bad? Chris Angelico <rosuav@gmail.com> - 2014-04-08 01:44 +1000
Re: Mutable objects inside tuples - good or bad? Paul Kölle <paul@subsignal.org> - 2014-04-07 21:46 +0200
Re: Mutable objects inside tuples - good or bad? Chris Angelico <rosuav@gmail.com> - 2014-04-08 08:47 +1000
Re: Mutable objects inside tuples - good or bad? Terry Reedy <tjreedy@udel.edu> - 2014-04-07 20:16 -0400
Re: Mutable objects inside tuples - good or bad? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-04-08 02:53 +0000
csiph-web