Re: About GIL Questions!
On Thu, Jun 20, 2013 at 2:13 PM, Thanatos xiao <email@example.com> 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?
> 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 08:11 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.