How many is "too many" with lists?

Jeff Raven jraven at psu.edu
Wed May 3 03:11:54 CEST 2000


On Tue, 02 May 2000 12:48:01 -0400, Matthew Hirsch <meh9 at cornell.edu> wrote:
>Generating the list is slow.  I'm accessing each element with a for 
>loop.  I was just curious.
>
>Matt
>
>

How are you generating them, and how slow is too slow? With some
optimized Python code on my rather sluggish P166 with 32meg I can
crank out a list of all 296010 combinations for C(27,6) in around
18-19 seconds -- a little worse if I make some conscessions in the
code to cut down own memory use (though in either case it eats up
most of my ram).

I suspect if you want to go faster you'd need to write it in C,
but this really is a problem where the algorithm can make a notable
difference (and once you've optimised it in python, the translation
to C almost writes itself).

Jeff Raven



More information about the Python-list mailing list