title: python creating new list using a "template list"
body: <p>Suppose i have:</p>
  <pre><code>x1 = [1, 3, 2, 4]
  </code></pre>
  <p>and:</p>
  <pre><code>x2 = [0, 1, 1, 0]
  </code></pre>
  <p>with the same shape</p>
  <p>now i want to &quot;put x2 ontop of x1&quot; and sum up all the numbers of x1 corresponding to the numbers of x2</p>
  <p>so the end result is:</p>
  <pre><code>end = [1+4 ,3+2]  # end[0] is the sum of all numbers of x1 where a 0 was in x2
  </code></pre>
  <p>this is a naive implementation using list to further clarify the question</p>
  <pre class="lang-py prettyprint-override"><code>store_0 = 0
  store_1 = 0
  x1 = [1, 3, 4, 2]
  x2 = [0, 1, 1, 0]
  for value_x1 ,value_x2 in zip(x1 ,x2):
      if value_x2 == 0:
          store_0 += value_x1
      elif value_x2 == 1:
          store_1 += value_x1
  </code></pre>
  <p>so my question:
  is there is a way to implement this in numpy without
  using loops or in general just faster?</p>