LWN.net Logo

It's not that bad.

It's not that bad.

Posted Sep 15, 2007 20:19 UTC (Sat) by moxfyre (subscriber, #13847)
In reply to: It's not that bad. by dw
Parent article: Changes ahead for Python

As repeated many zillions of times throughout the Internet, this is pretty acceptable for almost any application except heavily compute-bound programs, in which case the author would probably be wanting to use a language more suitable for high performance computational work to begin with.
Actually, if you're doing numerical work, like decomposing big matrices and vectors and such... Python is just great!!

That's because of the NumPy extension. It is a C extension, and when doing heavy computations it will happily use multiple threads. For example, I can make a huge random matrix and compute its eigenvalues and eigenvectors:

from numpy import *
big = random.random([1000,1000])     # matrix of random values in the [0,1] interval
eigval, eigvec = linalg.eig(big)
So you can write your algorithm in Python, but all the heavy-duty number crunching will happen in multi-threaded code in C.

If your Python program is CPU-bound but not because of number crunching, then I can see the GIL being more vexing. The case of CPU-bound web applications is probably very frustrating, since there's no easy way to factor out the CPU-bound stuff into an easily parallelizable C extension :-( Anybody have any thoughts on that?


(Log in to post comments)

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.