[EMAIL PROTECTED] wrote:
hi,
I'm not sure why this hasn't come up yet, but this seems to beg for
list comprehensions, if not generator expressions. All of the
following run in under 2 seconds on my old laptop:
alph = 'abcdefghijklmnopqrstuvwxyz'
len([''.join((a,b,c,d)) for a in alph
hi,
I'm not sure why this hasn't come up yet, but this seems to beg for
list comprehensions, if not generator expressions. All of the
following run in under 2 seconds on my old laptop:
alph = 'abcdefghijklmnopqrstuvwxyz'
len([''.join((a,b,c,d)) for a in alph for b in alph for c in alph for d
[EMAIL PROTECTED] wrote:
But it turns out he actually had one, which he graciously provided
in response to my observation. If I had kept my trap shut, I wouldn't
have it, would I?
I completely agree, but you could put your questions in
a way that increases your chances of helpful replies...
Magnus Lycka wrote:
[EMAIL PROTECTED] wrote:
But it turns out he actually had one, which he graciously provided
in response to my observation. If I had kept my trap shut, I wouldn't
have it, would I?
I completely agree, but you could put your questions in
a way that increases your
[EMAIL PROTECTED] wrote:
Magnus Lycka wrote:
[EMAIL PROTECTED] wrote:
But it turns out he actually had one, which he graciously provided
in response to my observation. If I had kept my trap shut, I wouldn't
have it, would I?
[...]
And, strange as it may seem, asking questions the
smart way
[EMAIL PROTECTED] wrote:
But using the free SDK compiler from MS? That seems elusive.
Have you seen this?
http://www.vrplumber.com/programming/mstoolkit/
--
http://mail.python.org/mailman/listinfo/python-list
Magnus Lycka wrote:
[EMAIL PROTECTED] wrote:
But using the free SDK compiler from MS? That seems elusive.
Have you seen this?
http://www.vrplumber.com/programming/mstoolkit/
I have, although I haven't tried it as I was able to get a GMPY
Windows binary from someone else. It may be that
On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote:
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
Jack Diederich wrote:
On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote:
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
[EMAIL PROTECTED] wrote:
It is a C extension that does permutations combinations and is
about 10x faster than doing it in pure python [I'm the author].
It is also the 3rd result for python combination and 5th for
python permutaiton but every month someone posts to c.l.py asking
for
On Thu, Feb 09, 2006 at 10:23:12AM -0800, [EMAIL PROTECTED] wrote:
Jack Diederich wrote:
On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote:
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
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
It is a C extension that does permutations combinations and is
about 10x faster than doing it in pure python [I'm the author].
It is also the 3rd result for python combination and 5th for
python permutaiton but every month someone posts
[EMAIL PROTECTED] wrote:
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
It is a C extension that does permutations combinations and is
about 10x faster than doing it in pure python [I'm the author].
It is also the 3rd result for python combination and 5th for
python
[EMAIL PROTECTED] wrote:
Fredrik Lundh wrote:
Windows don't support C ? that was a new one.
Windows comes with a C compiler? That's news to me.
It doesn't come with Python either. Both Python and
the compiler etc that you need can be freely downloaded
from the internet. I suggest you leave
Magnus Lycka wrote:
[EMAIL PROTECTED] wrote:
Fredrik Lundh wrote:
Windows don't support C ? that was a new one.
Windows comes with a C compiler? That's news to me.
It doesn't come with Python either. Both Python and
the compiler etc that you need can be freely downloaded
from the
Jack Diederich wrote:
On Thu, Feb 09, 2006 at 10:23:12AM -0800, [EMAIL PROTECTED] wrote:
Jack Diederich wrote:
On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote:
Hi there,
I've got a reasonably sized list of objects that I'd like to pull out
all combinations of five
liberally snipped out parts
On Thu, Feb 09, 2006 at 03:25:18PM -0800, [EMAIL PROTECTED] wrote:
Jack Diederich wrote:
On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote:
I've got a reasonably sized list of objects that I'd like to pull out
all combinations of five elements
Jack Diederich wrote:
liberally snipped out parts
On Thu, Feb 09, 2006 at 03:25:18PM -0800, [EMAIL PROTECTED] wrote:
Jack Diederich wrote:
On Wed, Feb 08, 2006 at 12:50:19PM -0800, Swroteb wrote:
I've got a reasonably sized list of objects that I'd like to pull
out
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:
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 do it using a standard paradigm using
five indexed for loops (ie, for i = 1, for j = i+1,
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 do it using a standard paradigm using
five indexed for loops (ie,
Swroteb [EMAIL PROTECTED] writes:
I'm a little bit confused about your generator suggestion. My list is
a set of references to instantiated objects. I'm just unsure about how
to iterate through every unique combination of those references. Are
you suggesting that I set up methods to provide
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==0:
Ah, this definitely seems to work! It's a lot nicer in appearance than
my previous code, that's for sure. It actually runs in approximately
the same amount of time though.
As a side note, this problem will always be slow. The number of
combinations grows exponentially with n. No matter how
Swroteb wrote:
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
Michael Spencer [EMAIL PROTECTED] 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
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
27 matches
Mail list logo