Christian Meesters wrote: > Hi, > > I'd like to hack a function which returns all possible permutations as lists > (or tuples) of two from a given list. So far, I came up with this solution, > but it turned out to be too slow for the given problem, because the list > passed ("atomlist") can be some 1e5 items long:
<snip> > > Does anybody know a solution which consumes less memory and is possibly > faster, perhaps using generator expressions? All my attempts so far failed. No claims with respect to speed, but the kslice function here: http://gflanagan.net/site/python/utils/sequtils/ will give the 'k-subsets' which then need to be permuted - alternatively Google. Gerard -- http://mail.python.org/mailman/listinfo/python-list