Fast generation of permutations

Frode Øijord frodo at sim.no
Wed Jan 25 12:18:51 EST 2006


Jack Diederich wrote:

> You might want to look at a specific purpose library for poker hands:
> http://pokersource.sourceforge.net/

Nah, evaluating the poker hands is the FUN part! I want to do that myself :)

> If you really want to do combinations a C extension has already 
> been written (by me).
> 
> http://probstat.sourceforge.net/
> 
> import probstat
> cards = range(52)
> for (hand) in probstat.Combination(card, 5):
>   pass
> 
> Takes 1.3 seconds on my laptop instead of 17 seconds for the pure
> python version which is only one order of magnitude faster.

This is *exactly* what i wanted! I just installed it and the hand 
generation is down to around 1.2 seconds now, and that I can live with 
:) Now I just have to reduce the running time of the actual hand 
evaluation with an order of magnitude... ;)

Thanks!

-- 
Frode, SIM

"Any fool can write code that a computer can understand.
  Good programmers write code that humans can understand"



More information about the Python-list mailing list