title: Dividing a for loop for each process
body: <p>I have this code:</p>
  
  <pre><code>def loop():
      alphabet = string.digits + string.letters
      for key in itertools.product(alphabet, repeat=6):
      ...
  </code></pre>
  
  <p>I am using 4 processes using this code: </p>
  
  <pre><code>if __name__ == '__main__':
      jobs = []
      for i in range(4):
          p = multiprocessing.Process(target=loop)
          jobs.append(p)
          p.start()
  </code></pre>
  
  <p>Now.. this will just run the entire function 4 times, I need to somehow split the workload into 4 and run each process on its own, so in this case I need to split the characters I'm generating into 4 different parts.. for example:</p>
  
  <p>Process 1 workload</p>
  
  <p>100,101,102,103</p>
  
  <p>Process 2 workload</p>
  
  <p>104,105,106,107</p>
  
  <p>Process 3 workload</p>
  
  <p>108,109,110,111</p>
  
  <p>Process 4 workload</p>
  
  <p>112,113,114,115</p>
  
  <p>I think you should understand what I want to do..</p>
  
  <p>I tried looping through and just throwing away but it can get super slow when using a large length of characters.. If I had 1,000,000 lines and the processor name was 4, it will loop 750,000 times without doing anything and process the next 250,000, if the processor name was 3.. it would loop 500,000 times, process the next 250k and finish at 75000, so much wasted computing power though :/</p>