Re:Code Like a Pythonista: Idiomatic Python
by Goladus on Saturday October 22, 2011 @08:55PM
(#3144778)
My guess is that it's optimized, but I don't know. Semantics-wise, it's consistent with list addition.
>>> [0] + [0] + [0]
[0, 0, 0]
>>> [0] * 3
[0, 0, 0]
Re:Code Like a Pythonista: Idiomatic Python
by Ixiaus on Saturday October 22, 2011 @09:05PM
(#3144801)
I just read, that syntax is sugar for the list.extend() method so it's still making copies of the list - I wouldn't use it for a list containing complex objects; but that is very idiomatic for simple use cases (like this one?).
Re:Code Like a Pythonista: Idiomatic Python
by calpaterson on Sunday October 23, 2011 @05:08AM
(#3145667)
It isn't syntax - help(list.__mul__)
Is it efficient though?