Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82267 > unrolled thread

Re: Nested loops is strangely slow, totally at a loss.

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2014-12-10 00:13 -0700
Last post2014-12-10 00:13 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Nested loops is strangely slow, totally at a loss. Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-10 00:13 -0700

#82267 — Re: Nested loops is strangely slow, totally at a loss.

FromIan Kelly <ian.g.kelly@gmail.com>
Date2014-12-10 00:13 -0700
SubjectRe: Nested loops is strangely slow, totally at a loss.
Message-ID<mailman.16799.1418195682.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

On Tue, Dec 9, 2014 at 11:30 PM, Chris Angelico <rosuav@gmail.com> wrote:
> Are you sure it isn't? Your 'space' is an iterable cubic
> cross-product. Your first loop checks (0,0,0) which is the first
> element returned, and is thus fast... but it also *consumes* that
> first element. The next time you test it, the entire space gets
> consumed, looking for another (0,0,0), which won't exist. That means
> iterating over 580**3 == 195112000 (two hundred million) tuples, and
> that *is* going to be slow.

Huh, I wasn't even aware that membership tests worked on iterables with no
__contains__ method. Seems odd to me that 'x in y' should be supported but
not 'len(y)'.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web