Questions about GIL and web services from a n00b
sturlamolden at yahoo.no
Sun Apr 17 17:49:35 CEST 2011
On Apr 17, 5:15 pm, Ian <hobso... at gmail.com> wrote:
> > 5) Even in CPython, I/O-bound processes are not slowed significantly
> > by the GIL. It's really CPU-bound processes that are.
> Its ONLY when you have two or more CPU bound threads that you may have
And when you have a CPU bound thread, it's time to find the offending
bottleneck and analyse the issue.
Often it will be a bad choise of algorithm, for example one that is
O(N**2) instead of O(N log N). If that is the case, it is time to
If algoritmic complexity is not the problem, it is time to remember
that Python gives us a 200x speed penalty over C. Moving the
code to a C library might give a sufficent speed boost.
If even that does not help, we could pick a library that uses
multi-threading internally, or we could release the GIL and use
multiple threads from Python. And if the library is not thread-safe,
it is time to use multiprocessing.
More information about the Python-list