title: multiprocessing sum python
body: <p>I have the following code.</p>
  <pre><code>from itertools import repeat
  from multiprocessing import Pool
  import os
  import numpy as np
  
  a=[1,2,3]
  b=[2,3,4]
  
  def multi_run_wrapper(args):
      return add(*args)
  def add(x,y):
      return x+y
  
  
  if __name__ == &quot;__main__&quot;:
      pool = Pool( os.cpu_count())
      results = pool.starmap(add,zip(a,b))
      print(sum(results))
  </code></pre>
  <p>the output would be <code>results= [3, 5, 7]</code>.  and  print out <code>15</code>.
  So in this way, if I want to calculate sum of <code>results</code>, I need to save the whole list <code>results</code>.
  Is there a way of using multiprocessing without saving the whole list? For example, sum the <code>results</code> while using mulprocessing. Because if my list <code>a</code> and <code>b</code> become super long, then the output <code>results</code> would take too much memory and it won't fit in my laptop.
  In other words, my goal is to get <code>sum(results)</code> without saving the whole list but speed up the process at the same time.</p>
  <p>Thank you</p>