Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48771

Re: About GIL Questions!

Path csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'forgive': 0.05; 'everyone!': 0.07; 'subject:Questions': 0.07; 'runs': 0.10; 'python': 0.11; 'mostly': 0.14; 'thread': 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instances,': 0.16; 'layery': 0.16; 'massively': 0.16; 'objects.': 0.16; 'subject:GIL': 0.16; '(you': 0.16; 'wrote:': 0.18; 'hey': 0.18; 'library': 0.18; 'thu,': 0.19; 'code,': 0.22; 'separate': 0.22; 'module,': 0.24; 'source': 0.25; 'first,': 0.26; 'header:In- Reply-To:1': 0.27; 'operations,': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'second,': 0.31; 'subject:About': 0.31; 'thanks!': 0.32; 'run': 0.32; 'core': 0.34; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'accessing': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; "you're": 0.61; 'different': 0.65; 'between': 0.67; 'bottom': 0.67; '20,': 0.68; 'quicker': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=XeMPyudZ5R+JXDWFT0TTED2myOaeRi475Kt9eeeajcc=; b=sKbtKOGuwkVclpYsRxdowjoAzI0Lb1xsxfrA2mJjNvR/LUzOd1WHHNrW+yfLzqbtjQ zzFthAhcxkiO9+WUFaF8l9Xa3XSTP8+xQ4kC+FFKdmjKvr4a6RMmv1e0Pti4sQzn/Tvk wjGcAD3AXNQENzgFuS5IrX3NtWErOwhge8oCpCw+idYAy2VFnxOZMphHqQQsGP/lqU9f UDR7Ak8nT1YvASJdM06+CQ06G9NQb365YxViJvjyfYvSY1PefvG1CcyaFfiJO+sQveDu 5NdIAkcO0Q5HQOR1XaalBbhXrOfxlaIkBHMVELkNQxshSr4yDVjFrc3ldwf6SSIVsHaL ddsA==
MIME-Version 1.0
X-Received by 10.220.48.17 with SMTP id p17mr1748454vcf.97.1371701979103; Wed, 19 Jun 2013 21:19:39 -0700 (PDT)
In-Reply-To <CAF0POctYGbN39_B_k9kgrDDqhstvBBDXonTpzkG_Tm7DHwto=Q@mail.gmail.com>
References <CAF0POctYGbN39_B_k9kgrDDqhstvBBDXonTpzkG_Tm7DHwto=Q@mail.gmail.com>
Date Thu, 20 Jun 2013 14:19:39 +1000
Subject Re: About GIL Questions!
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3607.1371701982.3114.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371701982 news.xs4all.nl 15971 [2001:888:2000:d::a6]:50262
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:48771

Show key headers only | View raw


On Thu, Jun 20, 2013 at 2:13 PM, Thanatos xiao <yanxiaopei199@gmail.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?
>
> 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.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: About GIL Questions! Chris Angelico <rosuav@gmail.com> - 2013-06-20 14:19 +1000

csiph-web