Is len O(n) or O(1) ?

Fredrik Lundh fredrik at pythonware.com
Thu Sep 11 05:34:16 EDT 2008


process wrote:

> Python uses arrays for lists right?

len is O(1).  for other operations, see

    http://effbot.org/zone/python-list.htm#performance

 > def quicksort(lista):
 >     if lista == []:
 >         lista

better make that:

    def quicksort(lista):
        if not lista:
            return lista
        ...

</F>




More information about the Python-list mailing list