title: One-line & multi-line loops and vectorization in Python
body: <p>Can one-line loops in Python only be used to build lists? (i.e. list comprehensions), or can they use for more general computing?</p>
  
  <p>For example, I am aware that list comprehensions (~single-line loop) in Python, e.g.</p>
  
  <pre><code>my_list = [ 2*i for i in range(10)]
  </code></pre>
  
  <p>can also be built with a multi-line loop:</p>
  
  <pre><code>my_list = []
  for i in range(10):
      my_list.append(2*i)
  </code></pre>
  
  <p>But can we <strong>always</strong> transform general multi-line loops into one-line loops?</p>
  
  <p>For example, say we have the following multi-line for loop:</p>
  
  <pre><code>my_array = np.ones(10*10)
  
  for x in range(10):
       my_array[x,:] = 0
  </code></pre>
  
  <p>can we convert it into a single-line loop? More generally:</p>
  
  <p><strong>Q1.</strong> Are the two forms functionally equivalent? (i.e. they support the same set of manipulations/operations)</p>
  
  <p><strong>Q2.</strong> I think I have read before  that one-line loops in Python are <strong>vectorized</strong>. Is this true? And does this mean that they can <strong>iterate faster</strong> than multi-line loops?</p>