Velocity Reviews

Velocity Reviews (
-   Python (
-   -   Re: About GIL Questions! (

Chris Angelico 06-20-2013 04:19 AM

Re: About GIL Questions!
On Thu, Jun 20, 2013 at 2:13 PM, Thanatos xiao <> wrote:
> Hey everyone!
> Recently I see the python source code, but i still not understand about gil.
> first, why single core quicker multi-core ? who can explan this in bottom
> layery ?
> second, what the different between the mult-core and the single core to
> schecule threads?
> thanks!
> Forgive me bad english!

The GIL, massively simplified: One thread at a time can be accessing
Python objects. That means that Python threads are good for I/O-bound
operations (you can have three threads all waiting on the network at
once), but not for CPU-bound operations, unless you're calling on a
library that deliberately releases the GIL.

But if you want to run Python code across multiple cores, you can use
the multiprocessing module, which runs separate Python instances, so
they have separate GILs. You then can share data between them in a few
ways, but they're mostly separate.


All times are GMT. The time now is 07:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.