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


Groups > comp.lang.python > #45546

Re: Please help with Threading

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'explicitly': 0.05; 'interpreter': 0.05; 'that?': 0.05; 'interpreter.': 0.07; 'plenty': 0.07; 'subject:help': 0.08; 'bits': 0.09; 'themselves,': 0.09; 'window.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'thread': 0.14; '(either': 0.16; 'compute': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'url:dabeaz': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'seems': 0.21; 'manual': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'driver': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'header :In-Reply-To:1': 0.27; "doesn't": 0.30; 'went': 0.31; 'libraries': 0.31; 'releasing': 0.31; 'run': 0.32; 'url:python': 0.33; 'call.': 0.33; 'device': 0.34; 'subject:with': 0.35; 'info': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'received:com.au': 0.36; 'doing': 0.36; "didn't": 0.36; 'charset :us-ascii': 0.36; 'depends': 0.38; 'received:211': 0.38; 'either': 0.39; 'release': 0.40; 'even': 0.60; 'catch': 0.60; 'content- disposition:inline': 0.62; 'making': 0.63; 'such': 0.63; 'more': 0.64; 'between': 0.67; 'url:pdf': 0.68; 'ncr': 0.84; 'carlos': 0.91
Date Sun, 19 May 2013 13:10:36 +1000
From Cameron Simpson <cs@zip.com.au>
To Carlos Nepomuceno <carlosnepomuceno@outlook.com>
Subject Re: Please help with Threading
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <BLU176-W444B989132C26C3A305CB7D7AE0@phx.gbl>
User-Agent Mutt/1.5.21 (2010-09-15)
References <BLU176-W444B989132C26C3A305CB7D7AE0@phx.gbl>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.0 cv=e4Ne0tV/ c=1 sm=1 a=wom5GMh1gUkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=mYyBNZbq9KIA:10 a=UqCG9HQmAAAA:8 a=IZVGuq1iAAAA:8 a=Mzf4kn9LTQjjCuPADF4A:9 a=CjuIK1q_8ugA:10 a=4JFMnUiinsEA:10 a=ChdAjXE5lkUvdteQbhpnkQ==:117
Cc "python-list@python.org" <python-list@python.org>
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.1830.1368934672.3114.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368934672 news.xs4all.nl 15913 [2001:888:2000:d::a6]:36194
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45546

Show key headers only | View raw


On 19May2013 03:02, Carlos Nepomuceno <carlosnepomuceno@outlook.com> wrote:
| Just been told that GIL doesn't make things slower, but as I
| didn't know that such a thing even existed I went out looking for
| more info and found that document:
| http://www.dabeaz.com/python/UnderstandingGIL.pdf
| 
| Is it current? I didn't know Python threads aren't preemptive.
| Seems to be something really old considering the state of the art
| on parallel execution on multi-cores.
| What's the catch on making Python threads preemptive? Are there any ongoing projects to make that?

Depends what you mean by preemptive. If you have multiple CPU bound
pure Python threads they will all get CPU time without any of them
explicitly yeilding control. But thread switching happens between
python instructions, mediated by the interpreter.

The standard answers for using multiple cores is to either run
multiple processes (either explicitly spawning other executables,
or spawning child python processes using the multiprocessing module),
or to use (as suggested) libraries that can do the compute intensive
bits themselves, releasing the while doing so so that the Python
interpreter can run other bits of your python code.

Plenty of OS system calls (and calls to other libraries from the
interpreter) release the GIL during the call. Other python threads
can run during that window.

And there are other Python implementations other than CPython.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

Processes are like potatoes.    - NCR device driver manual

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


Thread

Re: Please help with Threading Cameron Simpson <cs@zip.com.au> - 2013-05-19 13:10 +1000

csiph-web