title: Using generator instead of nested loops
body: <p>I have the following nested loop. But it is inefficient time wise. So using a generator would be much better. Do you know how to do that?</p>
  
  <pre><code>x_sph[:] = [r*sin_t*cos_p for cos_p in cos_phi for sin_t in sin_theta for r in p]     
  </code></pre>
  
  <p>It seems like some of you are of the opinion (looking at comments) that using a generator was not helpful in this case. I am under the impression that using generators will avoid assigning variables to memory, and thus save memory and time. Am I wrong?</p>