Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'yet.': 0.04; 'irc': 0.05; 'debug': 0.07; 'immutable': 0.09; 'naturally': 0.09; 'read-only': 0.09; 'style.': 0.09; 'things,': 0.09; 'python': 0.11; 'cheers': 0.12; 'suggest': 0.14; 'thread': 0.14; 'believes': 0.16; 'complaining': 0.16; 'concurrency': 0.16; 'concurrency,': 0.16; 'concurrent': 0.16; 'fancy': 0.16; 'ironpython': 0.16; 'java.': 0.16; 'mutable': 0.16; 'numpy': 0.16; 'reminded': 0.16; 'respected': 0.16; 'sequential': 0.16; 'simplest': 0.16; 'subject:Pypy': 0.16; 'threads.': 0.16; 'twisted': 0.16; 'prevent': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'trying': 0.19; 'numerical': 0.19; 'passing': 0.19; 'pieces': 0.19; 'written': 0.21; 'seems': 0.21; 'feb': 0.22; 'machine': 0.22; 'memory': 0.22; 'example': 0.22; 'programming': 0.22; 'separate': 0.22; '(such': 0.24; 'url:02': 0.24; 'paul': 0.24; "haven't": 0.24; "i've": 0.25; '>': 0.26; 'performing': 0.26; 'task': 0.26; 'to:2**1': 0.27; 'point': 0.28; 'generally': 0.29; 'involving': 0.30; 'needed.': 0.30; 'primarily': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'that.': 0.31; '"do': 0.31; 'bad.': 0.31; 'bunch': 0.31; 'libraries': 0.31; 'releasing': 0.31; 'so-called': 0.31; 'staying': 0.31; 'stuff': 0.32; 'url:python': 0.33; 'running': 0.33; 'style': 0.33; 'core': 0.34; 'maybe': 0.34; 'problem.': 0.35; 'something': 0.35; 'etc.)': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'wrong': 0.37; 'sometimes': 0.38; 'problems': 0.38; 'to:addr:python-list': 0.38; 'previous': 0.38; 'anything': 0.39; 'recent': 0.39; 'channel': 0.39; "couldn't": 0.39; 'moving': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'url:mail': 0.40; 'even': 0.60; 'algorithms': 0.60; 'is.': 0.60; 'problems.': 0.60; 'solve': 0.60; 'most': 0.60; 'helps': 0.61; 'length': 0.61; 'effective': 0.61; "you're": 0.61; 'times': 0.62; 'hear': 0.63; 'different': 0.65; 'great': 0.65; 'specialized': 0.65; 'here': 0.66; 'believe': 0.68; 'beautiful': 0.68; 'gotten': 0.74; 'programs,': 0.74; 'removal': 0.74; 'gain': 0.79; '"do': 0.84; '2015': 0.84; 'acquiring': 0.84; 'alternative.': 0.84; 'bitten': 0.84; 'crowd': 0.84; 'sometimes.': 0.84; 'url:2014': 0.84; 'erlang': 0.91; 'horror': 0.91; 'processes,': 0.91; 'shares': 0.93; 'hot': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:from:date:message-id:subject:to :content-type; bh=94V314b6w83EmLjViqTajr19NhNCUbNemZCQbcZi9R8=; b=LevvY7wlv/TIAJMJ1ZJr5sRq1oXaUoDNTmUUrT1IRvHGtf71nPYi2qS2SgDthhWvGA r7CBumwB5pTRWigG2te4VovWrP71rrOf6eV5cVOo0ZvNFk9IgZyUhGDF35v3FGsgZQzp rL2rPRjhyvRlxN2m1MgMhrWEdFtGRa19bZmPNHXXE2idxajBQ5haG0o/9yIzyTgyAlfy gvalUm/Bs7IyT77KVchl+KFTQYPRHN5T9FUJitt/o+DjGOz9OznmZRyrMT0fFwmW022M 6/GmGTNFhuQetxuvUthLgdIfsoR15m0EyjnFr1FZhjp09cKjfQmNJVKCcnCrZyues2uU 2hAw== X-Received: by 10.68.254.168 with SMTP id aj8mr15547049pbd.80.1424661400303; Sun, 22 Feb 2015 19:16:40 -0800 (PST) MIME-Version: 1.0 References: <87fv9xdb22.fsf@jester.gateway.pace.com> <54ea7ff4$0$12983$c3e8da3$5496439d@news.astraweb.com> <87zj85bcyu.fsf@jester.gateway.pace.com> From: Ryan Stuart Date: Mon, 23 Feb 2015 03:16:39 +0000 Subject: Re: Future of Pypy? To: Paul Rubin , python-list@python.org Content-Type: multipart/alternative; boundary=047d7b2e1365b0c1df050fb8d401 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 227 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424661403 news.xs4all.nl 2855 [2001:888:2000:d::a6]:52907 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 15513 X-Received-Body-CRC: 2417011697 Xref: csiph.com comp.lang.python:86186 --047d7b2e1365b0c1df050fb8d401 Content-Type: text/plain; charset=UTF-8 On Mon Feb 23 2015 at 12:05:46 PM Paul Rubin wrote: > I don't see what the big deal is. I hear tons of horror stories about > threads and I believe them, but the thing is, they almost always revolve > around acquiring and releasing locks in the wrong order, forgetting to > lock things, stuff like that. So I've generally respected the terror > and avoided programming in that style, staying with a message passing > style that may take an efficiency hit but seems to avoid almost all > those problems. TM also helps with lock hazards and it's a beautiful > idea--I just haven't had to use it yet. The Python IRC channel seems to > rage against threads and promote Twisted for concurrency, but Twisted > has always reminded me of Java. I use threads in Python all the time > and haven't gotten bitten yet. > > Many people have written at length about why it's bad. The most recent example I have come across is here -> https://glyph.twistedmatrix.com/2014/02/unyielding.html It's not a specific Python problem. I must be in the limited crowd that believes that the GIL is a *feature* of Python. Then again, maybe it isn't so limited since the GIL-less python implementations haven't really taken off. I have yet to come across a scenario I couldn't solve with either Processes, NumPy or event loops. Yes, when using processes, the passing of data can be annoying sometimes. But that is far less annoying then trying to debug something that shares state across threads. It's great that you haven't been bitten yet. But, the evidence seems to suggest the either you *will* be bitten at some point or, you already have been, and you just don't know it. Cheers > > Writing multithreaded code is *hard*. It is not a programming model > > which comes naturally to most human beings. Very few programs are > > inherently parallelizable, although many programs have *parts* which > > can be successfully parallelized. > > Parallel algorithms are complicated and specialized but tons of problems > amount to "do the same thing with N different pieces of data", so-called > embarassingly parallel. The model is you have a bunch of worker threads > reading off a queue and processing the items concurrently. Sometimes > separate processes works equally well, other times it's good to have > some shared data in memory instead of communicating through sockets. If > the data is mutable then have one thread own it and access it only with > message passing, Erlang style. If it's immutable after initialization > (protect it with a condition variable til initialization finishes) then > you can have read-only access from anywhere. > > > if you're running single-thread code on a single-core machine and > > still complaining about the GIL, you have no clue. > > Even the Raspberry Pi has 4 cores now, and fancy smartphones have had > them for years. Single core cpu's are specialized and/or historical. > > > for some programs, the simplest way to speed it up is to vectorize the > > core parts of your code by using numpy. No threads needed. > > Nice for numerical codes, not so hot for anything else. > > > Where are the people flocking to use Jython and IronPython? > > Shrug, who knows, those implementations were pretty deficient from what > heard. > > > For removal of the GIL to really make a difference: ... > > - you must be performing a task which is parallelizable and not > inherently > > sequential (no point using multiple threads if each thread spends all its > > time waiting for the previous thread); > > That's most things involving concurrency these days. > > > - the task must be one that moving to some other multi-processing model > > (such as greenlets, multiprocess, etc.) is infeasible; > > I don't understand this--there can be multiple ways to solve a problem. > > > - your threading bottleneck must be primarily CPU-bound, not I/O bound > > (CPython's threads are already very effective at parallelising I/O > tasks); > > If your concurrent program's workload makes it cpu-bound even 1% of the > time, then you gain something by having it use your extra cores at those > moments, instead of having those cores always do nothing. > > > - and you must be using libraries and tools which prevent you moving to > > Jython or IronPython or some other alternative. > > I don't get this at all. Why should I not want Python to have the same > capabilities? > -- > https://mail.python.org/mailman/listinfo/python-list > --047d7b2e1365b0c1df050fb8d401 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Mon Feb 23 2015 at 12:05:46 = PM Paul Rubin <no.email@nospam.invalid> wrote:
I don't see what the big deal is.=C2=A0 I hear tons of ho= rror stories about
threads and I believe them, but the thing is, they almost always revolve around acquiring and releasing locks in the wrong order, forgetting to
lock things, stuff like that.=C2=A0 So I've generally respected the ter= ror
and avoided programming in that style, staying with a message passing
style that may take an efficiency hit but seems to avoid almost all
those problems.=C2=A0 TM also helps with lock hazards and it's a beauti= ful
idea--I just haven't had to use it yet.=C2=A0 The Python IRC channel se= ems to
rage against threads and promote Twisted for concurrency, but Twisted
has always reminded me of Java.=C2=A0 I use threads in Python all the time<= br> and haven't gotten bitten yet.


Many people have written at length abo= ut why it's bad. The most recent example I have come across is here -&g= t;=C2=A0https://glyph.twistedmatrix.com/2014/02/unyielding.html

=
It's not a specific Python problem. I must be in the limited= crowd that believes that the GIL is a *feature* of Python. Then again, may= be it isn't so limited since the GIL-less python implementations haven&= #39;t really taken off.

I have yet to come across = a scenario I couldn't solve with either Processes, NumPy or event loops= . Yes, when using processes, the passing of data can be annoying sometimes.= But that is far less annoying then trying to debug something that shares s= tate across threads.

It's great that you haven= 't been bitten yet. But, the evidence seems to suggest the either you *= will* be bitten at some point or, you already have been, and you just don&#= 39;t know it.

Cheers
=C2=A0
> Writing multithreaded code is *hard*. It is not a programming model > which comes naturally to most human beings. Very few programs are
> inherently parallelizable, although many programs have *parts* which > can be successfully parallelized.

Parallel algorithms are complicated and specialized but tons of problems amount to "do the same thing with N different pieces of data", so= -called
embarassingly parallel.=C2=A0 The model is you have a bunch of worker threa= ds
reading off a queue and processing the items concurrently.=C2=A0 Sometimes<= br> separate processes works equally well, other times it's good to have some shared data in memory instead of communicating through sockets.=C2=A0 = If
the data is mutable then have one thread own it and access it only with
message passing, Erlang style.=C2=A0 If it's immutable after initializa= tion
(protect it with a condition variable til initialization finishes) then
you can have read-only access from anywhere.

> if you're running single-thread code on a single-core machine and<= br> > still complaining about the GIL, you have no clue.

Even the Raspberry Pi has 4 cores now, and fancy smartphones have had
them for years.=C2=A0 Single core cpu's are specialized and/or historic= al.

> for some programs, the simplest way to speed it up is to vectorize the=
> core parts of your code by using numpy.=C2=A0 No threads needed.

Nice for numerical codes, not so hot for anything else.

> Where are the people flocking to use Jython and IronPython?

Shrug, who knows, those implementations were pretty deficient from what
heard.

> For removal of the GIL to really make a difference: ...
> - you must be performing a task which is parallelizable and not inhere= ntly
> sequential (no point using multiple threads if each thread spends all = its
> time waiting for the previous thread);

That's most things involving concurrency these days.

> - the task must be one that moving to some other multi-processing mode= l
> (such as greenlets, multiprocess, etc.) is infeasible;

I don't understand this--there can be multiple ways to solve a problem.=

> - your threading bottleneck must be primarily CPU-bound, not I/O bound=
> (CPython's threads are already very effective at parallelising I/O= tasks);

If your concurrent program's workload makes it cpu-bound even 1% of the=
time, then you gain something by having it use your extra cores at those moments, instead of having those cores always do nothing.

> - and you must be using libraries and tools which prevent you moving t= o
> Jython or IronPython or some other alternative.

I don't get this at all.=C2=A0 Why should I not want Python to have the= same
capabilities?
--
https://mail.python.org/mailman/listinfo/python-list
--047d7b2e1365b0c1df050fb8d401--