What is a function parameter =[] for?

Chris Angelico rosuav at gmail.com
Wed Nov 25 22:02:00 EST 2015


On Thu, Nov 26, 2015 at 1:46 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Wed, Nov 25, 2015 at 7:25 PM, Chris Angelico <rosuav at gmail.com> wrote:
>> On Thu, Nov 26, 2015 at 1:08 PM, Alan Bawden <alan at csail.mit.edu> 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
>
> Well, he did say all "current" implementations. CPython 2.7 may still
> be supported, but that doesn't make it current. And anything at 2.5 is
> just archaic.

Those are the versions of Jython and PyPy available from the Debian
Jessie repositories. I'm not sure what Jython's compatibility is, but
this is at least reasonably current.

But I grabbed the latest 2.x-compatible PyPy nightly:

Python 2.7.10 (b4515dee6ebf, Nov 25 2015, 23:01:41)
[PyPy 4.1.0-alpha0 with GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``Every time someone argues with
"Smalltalk has always done X", it is always a good hint that something needs to
be changed fast. - Marcus Denker''
>>>> tuple([]) is tuple([])
False

The latest PyPy3 nightly builds seem to be broken, though; I was
unable to get one to run. The builds compatible with Python 3.2 work,
though:

Python 3.2.5 (b2091e973da6, Oct 19 2014, 18:29:55)
[PyPy 2.4.0 with GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> tuple([]) is tuple([])
False

So current PyPy still behaves that way.

ChrisA



More information about the Python-list mailing list