Surprising (for me) benchmark results...

Andrew Dalke dalke at acm.org
Tue May 1 23:43:40 EDT 2001


Rainer Deyke:
>Disk access is O(N); sorting is typically O(N log N).  Therefore as the
>number of entries in the file size increases, the time taken by the sort
>becomes more significant and the time taken by disk access becomes less
>significant.

If you want to consider things that way then you have to worry
about Python's list extension, which last I heard was O(N**2),
that is,

  data = []
  i = 0
  while i < N:
    data.append(i)

is an O(N**2) operation instead of O(N).  (Although
  data = list(range(N))
should be O(N) :)

But the likelyhood of this being a problem is low.  BTW, this was
discussed to death last year so please read the archives for
pros and cons to the current behaviour.

                    Andrew
                    dalke at acm.org






More information about the Python-list mailing list