Re: Pulling all n-sized combinations from a list

2006-02-08 Thread Swroteb
Yes, certainly. I hadn't done any profiling up to that point, but it really seemed like my biggest time sink was inefficiently losing time in obtaining the combinations. -- http://mail.python.org/mailman/listinfo/python-list

Re: Pulling all n-sized combinations from a list

2006-02-08 Thread Swroteb
Paul Rubin wrote: > I think the natural approach is to make a generator that yields a > 5-tuple for each combination, and then have your application iterate > over that generator. Here's my version: > > def comb(x,n): > """Generate combinations of n items from list x""" > if n

Re: Pulling all n-sized combinations from a list

2006-02-08 Thread Swroteb
Paul Rubin wrote: > "Swroteb" <[EMAIL PROTECTED]> writes: > > Atrocious and slow, I'm sure, but is there a better way? I can't > > simply create a list with the combinations I want, since it won't fit > > into memory. And I'm sure I can d

Pulling all n-sized combinations from a list

2006-02-08 Thread Swroteb
Hi there, I've got a reasonably sized list of objects that I'd like to pull out all combinations of five elements from. Right now I have a way to do this that's quite slow, but manageable. I know there must be a better way to do this, but I'm not sure what it is. Here's what I've got so far: