title: what is the neat way to divide huge nested loops to 8(or more) processes using Python?
body: <p>this time i'm facing a "design" problem. Using Python, I have a implement a mathematical algorithm which uses 5 parameters. To find the best combination of these 5 parameters, i used 5-layer nested loop to enumerate all possible combinations in a given range. The time it takes to finish appeared to be beyond my expectation. So I think it's the time to use multithreading... </p>
  
  <p>The task in the core of nested loops are calculation and saving. In current code, result from every calculation is appended to a list and the list will be written to a file at the end of program. </p>
  
  <p>since I don't have too much experience of multithreading in any language, not to mention Python, I would like to ask for some hints on what should the structure be for this problem. Namely, how should the calculations be assigned to the threads dynamically and how should the threads save results and later combine all results into one file. I hope the number of threads can be adjustable.</p>
  
  <p>Any illustration with code will be very helpful. </p>
  
  <p>thank you very much for your time, I appreciate it.</p>
  
  #
  
  <p>update of 2nd Day:
  thanks for all helpful answers, now I know that it is multiprocessing instead of multithreading. I always confuse with these two concepts because I think if it is multithreaded then the OS will automatically use multiple processor to run it when available. 
  I will find time to have some hands-on with multiprocessing tonight.</p>