title: Why list comprehension with many interactions is much slower than multiple list comprehensions?
body: <p>When I try to run a list comprehension with a large number of interactions, the command takes too long and does not output an answer. However, if I break it in small lists, I can get the job done.</p>
  <p>Example:
  This first one takes &quot;infinitely&quot;:</p>
  <pre><code>cl = [bool(sum([x in c_groups.index[k] for x in bb_sorted.columns[5:11]])) for k in range(len(c_groups))]
  </code></pre>
  <p>While this works just fine in a reasonable time:</p>
  <pre><code>cl1 = [bool(sum([x in c_groups.index[k] for x in bb_sorted.columns[5:11]])) for k in range(1000)]
  cl2 = [bool(sum([x in c_groups.index[k] for x in bb_sorted.columns[5:11]])) for k in range(1000,2000)]
  cl3 = [bool(sum([x in c_groups.index[k] for x in bb_sorted.columns[5:11]])) for k in range(2000,3000)]
  cl4 = [bool(sum([x in c_groups.index[k] for x in bb_sorted.columns[5:11]])) for k in range(3000,len(c_groups))]
  cl = cl1 + cl2 + cl3 + cl4
  </code></pre>
  <p>I copied this example from something exactly as I wrote it, but I it happened also in other situations. I have no idea of what happens here, and it does not feel right to avoid problems breaking list comprehensions down like this.</p>
  <p>Why does this happen, and how to avoid it (without breaking sentences like that)?</p>
  <p><strong>EDIT:</strong></p>
  <p>I tried the same script again, and I found out that the error happens only when using Spyder (running in shell works fine). Thus, it must be an issue with the IDE, I suppose (makes sense?).</p>