How to detect the number of threads i can & i should run?
<p>i have a 6th generation Intel i5 Processor (4 cores, 3 ghZ) and 8 gigabytes of RAM. Let's assume i need to create a text file which includes every number from 0 to 999999999. </p>

<p>How can  i make it faster? How many threads i should use? 4 or more than 4? How many threads i should run and why?</p>

<p>Thanks for the answers &amp; comments. I couldn't try the multiprocessing module because i am on a vacation and my computer has 2 cores, it would be the same (1 for system, 1 for python.). But i will add the results with the multiprocessing as soon as i get home. So, here is my test results with a Intel Pentium Dual Core 1.80ghZ:</p>

<p>Without extra threads it took 4 seconds.<br>
With one extra thread it took 3 seconds.</p>

<p>After the second thread it didn't change. I tried with 3, 4 and 5 threads, every time it took 3 seconds.</p>

<p>Here are the codes;  </p>

<p><a href="http://paste.ubuntu.com/23098237/" rel="nofollow">http://paste.ubuntu.com/23098237/</a> > 1 thread</p>

<p><a href="http://paste.ubuntu.com/23098229/" rel="nofollow">http://paste.ubuntu.com/23098229/</a> > 2 thread</p>

<p><a href="http://paste.ubuntu.com/23098131/" rel="nofollow">http://paste.ubuntu.com/23098131/</a> > 3 thread</p>

<p><a href="http://paste.ubuntu.com/23098136/" rel="nofollow">http://paste.ubuntu.com/23098136/</a> > 4 thread</p>

<p><a href="http://paste.ubuntu.com/23098139/" rel="nofollow">http://paste.ubuntu.com/23098139/</a> > 5 thread</p>

<p>sorry, i couldn't paste the code here, it said "not properly formatted as code". i tried for like 10 minutes, (ctrl + k, 4 spaces) it didn't work, so i just posted it on paste.ubuntu.com</p>

python multithreading