Is Python a commercial proposition ?

Roy Smith roy at panix.com
Tue Jul 31 08:04:57 EDT 2012


In article <50177b4d$0$29867$c3e8da3$5496439d at news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> Do they consider that perhaps there are alternatives to threads?

There's basically two reasons people use threads.

First is because it's a convenient way to multiplex short-lived tasks on 
a single processor.  What people tend to forget is that we managed to do 
that before there were threads.  Event loops still work perfectly fine.  
For an interesting example, http://www.gevent.org/.

Second is because we have multiple long-lived, compute-bound tasks and 
want to be able to take advantage of multiple processors.  For that, 
multiprocessing works just fine most of the time.  And multiprocess has 
the advantage over multithreading in that the processes can run on 
different machines, so you're not limited by the number of cores you can 
get on a single CPU.

What multiprocessing doesn't give you is fine-grain task switching.  So 
we're left with the set of jobs which consist of many (but not more than 
the number of cores on one CPU) compute-bound tasks, that we know how to 
parallelize, and require fine-grain task switching.  Sure, that's an 
important set of jobs, but there's a whole huge world of computing that 
doesn't fit into that box.



More information about the Python-list mailing list