# Super simple example of parallelising a for loop with multiprocessing import multiprocessing def whatever(i): print i # The "if" container isn't necessary on Linux. However on Windows, without it # the code will generate a fork bomb and thousands of Python processes will be # spawned and basically mess everything up. if __name__ == '__main__': pool = multiprocessing.Pool() pool.map(whatever,range(10)) # Returns : #0 #1 #2 #4 #3 #6 #5 #8 #7 #9 # Note that they're out of order !! # Equivalent standard code : for i in range(10): print i # Returns #0 #1 #2 #3 #4 #5 #6 #7 #8 #9