[Tutor] Finding prime numbers script runs much faster when run via bash shell than idle

Peter Otten __peter__ at web.de
Sat Apr 2 09:04:46 CEST 2011


Jaime Gago wrote:

> I wrote a simple piece of code as an exercise to an online -free- class
> that finds prime numbers. When I run it via IDLE it's taking way more time
> than if I run it via a (bash) shell (on Os X 10.6) while doing $>python -d
> mypp.py
> 
> I'm really curious from a performance perspective as to what could cause
> such a noticeable difference.

Displaying text in Idle's Python Shell window has significant overhead

If you remove the line

>         print prime_counter, 'found so far'

from your script it should take roughly the same time to run via bash and in 
Idle.



More information about the Tutor mailing list