Guest User

Untitled

a guest
Jan 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. import multiprocessing as mp
  2.  
  3.  
  4. def f(huge_amount):
  5. count = 0
  6. for i in range(huge_amount):
  7. if i % 2:
  8. count += 1
  9. else:
  10. count -= 1
  11.  
  12.  
  13. if __name__ == '__main__':
  14. huge_amount = 100000000000
  15. cpus = mp.cpu_count()
  16. list_amount = [huge_amount] * cpus
  17. with mp.Pool(cpus) as p:
  18. p.map(f, list_amount)
Add Comment
Please, Sign In to add comment