Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!s3g2000vbf.googlegroups.com!not-for-mail From: sturlamolden Newsgroups: comp.lang.python Subject: Re: Questions about GIL and web services from a n00b Date: Sun, 17 Apr 2011 08:49:35 -0700 (PDT) Organization: http://groups.google.com Lines: 27 Message-ID: References: <4DA8734C.1080706@WindsorCircle.com> NNTP-Posting-Host: 46.212.104.145 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1303055375 1497 127.0.0.1 (17 Apr 2011 15:49:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 17 Apr 2011 15:49:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s3g2000vbf.googlegroups.com; posting-host=46.212.104.145; posting-account=jLVA4AoAAACnFl2D2gz1qNYFxA8AUnMb User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET4.0C),gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3406 On Apr 17, 5:15=A0pm, Ian wrote: > > 5) Even in CPython, I/O-bound processes are not slowed significantly > > by the GIL. =A0It's really CPU-bound processes that are. > > Its ONLY when you have two or more CPU bound threads that you may have > issues. 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 recode. If algoritmic complexity is not the problem, it is time to remember that Python gives us a 200x speed penalty over C. Moving the offending 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. Sturla