Pulling all n-sized combinations from a list

Paul Rubin http
Wed Feb 8 20:41:14 EST 2006


Michael Spencer <mahs at telcopartners.com> writes:
> This is roughly 30 times faster on my box than the general solution above

Good point.  You could probably improve the generator version some
(probably not 30x) by doing less list arithmetic and slicing though.
I just wrote it the most straightforward way I could.  You could
probably speed up the nested-loops version somewhat too, by keeping
track of the indices instead of doing all that list slicing.



More information about the Python-list mailing list