Path: csiph.com!news.mixmin.net!news.albasani.net!feeder.erje.net!1.eu.feeder.erje.net!bloom-beacon.mit.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!grapevine.lcs.mit.edu!not-for-mail From: Alan Bawden Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Wed, 25 Nov 2015 23:27:43 -0500 Organization: MIT Computer Science & Artificial Intelligence Lab Lines: 49 Message-ID: References: <56547C53.8030407@rece.vub.ac.be> <5654864E.2070906@rece.vub.ac.be> <56549324.8020607@rece.vub.ac.be> <56549F15.40206@rece.vub.ac.be> <5654B037.6020107@rece.vub.ac.be> <56550273$0$1585$c3e8da3$5496439d@news.astraweb.com> <5655f27b$0$1614$c3e8da3$5496439d@news.astraweb.com> NNTP-Posting-Host: daphne.csail.mit.edu Mime-Version: 1.0 Content-Type: text/plain X-Trace: grapevine.csail.mit.edu 1448512063 22850 128.52.129.29 (26 Nov 2015 04:27:43 GMT) X-Complaints-To: security@csail.mit.edu NNTP-Posting-Date: Thu, 26 Nov 2015 04:27:43 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:1TvYdVnNdlr/h+CeMAMTwbeMEds= Xref: csiph.com comp.lang.python:99526 Chris Angelico writes: > On Thu, Nov 26, 2015 at 1:08 PM, Alan Bawden wrote: >> (Note that nothing in the documentation I can find actually _guarantees_ >> that a Python implementation will only have one unique empty tuple, but >> I wouldn't be suprised if the following is nonetheless true in all >> current implementations: >> >> >>> tuple([]) is tuple([]) >> True >> >> ) > > Jython 2.5.3 (, Oct 8 2014, 03:39:09) > [OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.7.0_85 > Type "help", "copyright", "credits" or "license" for more information. >>>> tuple([]) is tuple([]) > False > > Python 2.7.8 (2.4.0+dfsg-3, Dec 20 2014, 13:30:46) > [PyPy 2.4.0 with GCC 4.9.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>>> tuple([]) is tuple([]) > False > > ChrisA I said I wouldn't be suprised if it was always true, but that doesn't imply that I need to be suprised if it is sometimes false! Having said that, I _am_ curious whether that remains False for various other variant expressions. "tuple([])" is actually a rather perverse way to obtain an empty tuple. How about plain "() is ()"? While "tuple([]) is tuple([])" is False is some implementations, it is still possible that "() is ()" is True in those same implementations, depending on how that compiles. An even more perverse way to obtain an empty tuple is "tuple(x for x in ())" and in fact in CPython: >>> tuple(x for x in ()) is tuple(x for x in ()) False If I had thought to try that earlier, I wouldn't have bothered making the parenthetical remark to are responding to -- because none of this has any relevance to my original point about "BUILD_TUPLE 0". -- Alan Bawden