Brewed in the hoppy city of San Francisco

Posts tagged algorithms

11 notes &

Random lookup algorithm #2

Thanks to @pims, I’ve changed the code from this morning to use generators instead of regular lists loaded in memory.

Here’s the output:

With lists:


With generators:

and the available RAM that I have on my machine right now :

I grabbed the snapshots right during run-time, and it takes the activity monitor about 2 seconds to update its info, which gave me enough time to capture the amount of memory used by the different scripts.

The source code for the generators is available here:

Filed under python, generators lists algorithms