May I drop list bracket from list?

Steven D'Aprano steve+comp.lang.python at
Thu Apr 23 14:20:11 CEST 2015

On Thu, 23 Apr 2015 09:12 pm, Jean-Michel Pichavant wrote:

> If both list1 and fword are lists, you can also write
> list1 = list1 + fword
> or
> list1 += fword

You can, but you shouldn't since it risks being very slow, especially the
first version. Repeated list addition has quadratic behaviour. It's okay if
you only add a few lists, but if there are thousands or millions of them,
it will be horribly slow. Using extend guarantees to modify the list in
place and avoid unnecessary copying of data.


More information about the Python-list mailing list