title: Is a function in a for loop declaration will be called for many times in Python?
body: <p>There is a function and a for loop:</p>
  
  <pre><code>def helper():
      return [1,2,3]
  
  for i in helper():
      print(i)
  </code></pre>
  
  <p>I am wondering if the helper function would only be called once at the initialization of the for loop. As I am thinking that if I call the function and assign the return array to a variable in advance, which would be used in the for loop like this:</p>
  
  <pre><code>def helper():
      return [1,2,3]
  temp = helper()
  for i in temp:
      print(i)
  </code></pre>
  
  <p>Is that with less time complexity?</p>
  
  <p>Thanks!</p>