[Tutor] How to list/process files with identical character strings

Steven D'Aprano steve at pearwood.info
Thu Jun 26 13:54:28 CEST 2014


On Wed, Jun 25, 2014 at 09:47:07PM -0700, Alex Kleider wrote:

> Thanks for elucidating this.  I didn't know that "several thousand" 
> would still be considered a small number.

On a server, desktop, laptop or notepad, several thousand is not many. 
My computer can generate a dict with a million items in less than a 
second and a half:

py> with Stopwatch():
...     d = {n: (3*n+2)**4 for n in range(1000000)}
...
time taken: 1.331450 seconds


and then process it in under half a second:

py> with Stopwatch():
...     x = sum(d[n] for n in range(1000000))
...
time taken: 0.429471 seconds
py> x
16200013499990999994000001300000

For an embedded device, with perhaps 16 megabytes of RAM, thousands of 
items is a lot. But for a machine with gigabytes of RAM, it's tiny.


-- 
Steven


More information about the Tutor mailing list