Fast generation of permutations

Terry Reedy tjreedy at udel.edu
Wed Jan 25 12:26:43 EST 2006


"Frode Øijord" <frodo at sim.no> wrote in message 
news:11tf35qjfeluka1 at corp.supernews.com...
> However, this is way too slow for my needs. I try to use this to
> generate all possible 5 card poker hands, but this takes around 17
> seconds on an Athlon 2200. That's a 2 orders of magnitude too slow for
> my needs.

The set of all possible 5-card poker hands is a constant.  It appears you 
need it over and over.  But it is not clear to me whether you only need a 
generator to iterate over the set or the whole set at once.  If the latter, 
one option is to generate it once, save to disk, and read it in.  I'd  try 
both marshal and cpickle modules for read-in time.

Terry J. Reedy






More information about the Python-list mailing list