|
|
|
In CPython, += on lists is an in-place operation, and += and extend is exactly the same operation (+= is even a bit faster, since operator dispatch is faster than method lookups).
Or in other words, the following should not raise an assertion error:
>>> a = []
>>> b = a
>>> a += [1]
>>> assert a == b
</F>
Fredrik |
Homepage |
06/10/17 - 6:52 am | #
|
|
Right. I think *sometimes* we used the idiom :
someList += [item]
When we should have just used append (code pre-dating my arrival I hasten to add). 
It is probably from changing these that we got the speed benefit from.
It's good to know that the inplace operations on Python lists are efficient. I wonder if that is guaranteed with IronPython ? I exect it is.
Fuzzyman |
Homepage |
06/10/17 - 9:27 am | #
|
|
|
Commenting by HaloScan
|