Shiyao Ma <i...@introo.me>: > Given a = [1, 2] > > a.extend(a) makes a = [1,2, 1,2] > > One might guess a.extend(a) would turn into an infinite loop. It turns > out here Python first gets all the items of `a' and then append them > to `a', so the infinite loop is avoided.
Functionally, Python's lists are not linked lists but, rather, vectors. > My question is, is there any doc on the behavior of things like this? No. It should be here: <URL: https://docs.python.org/3/reference/datamodel.html> It only states: The items of a list are arbitrary Python objects. and inexplicably muddies the waters by continuing: Lists are formed by placing a comma-separated list of expressions in square brackets. (Note that there are no special cases needed to form lists of length 0 or 1.) (which has nothing whatsoever to do with the data model). Marko -- https://mail.python.org/mailman/listinfo/python-list