Performance of int/long in Python 3

Roy Smith roy at panix.com
Wed Apr 3 09:25:06 EDT 2013


In article <1f2dnfPBhY54eMbMnZ2dnUVZ_oSdnZ2d at westnet.com.au>,
 Neil Hodgson <nhodgson at iinet.net.au> wrote:

> Roy Smith:
> 
> > On the other hand, how long did it take you to do the directory tree
> > walk required to find those million paths?  I'll bet a long longer than
> > 0.78 seconds, so this gets lost in the noise.
> 
>     About 2 minutes. But that's just getting an example data set. Other 
> data sets may be loaded more quickly from databases or files or be 
> created by processing. Reading the example data from a file takes around 
> the same time as sorting.

Fair enough.  In fact, given that reading the file from disk is O(n) and 
sorting it is O(n log n), at some point, the sort will totally swamp the 
input time.  Your original example just happened to be one of the 
unusual cases where the sort time is not the rate limiting factor in the 
overall process.

I remember reading somewhere that more CPU cycles in the entire history 
of computing have been spend doing sorting than anything else.



More information about the Python-list mailing list