git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a,b = 2,3 and [a,b] = [2,3]


Eko palypse <ekopalypse at gmail.com> writes:

> Am Montag, 2. September 2019 00:49:05 UTC+2 schrieb Hongyi Zhao:
> > Hi,
> > 
> > What's differences:
> > 
> > a,b = 2,3 and [a,b] = [2,3]
> > 
> > Regards
> 
> In this example the result is the same but the second one
> builds, internally, an additional list, therefore isn't as sufficient
> as the first one.

It looks to me like they generate identical code.  The first one calls the
construction of a tuple, where the second one calls for the construction of
a list.  It would be surprising if the compiler optimized the tuple
away, but failed to optimize the list away!

-- 
Alan Bawden