Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46091
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <carlosnepomuceno@outlook.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.030 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; 'parameters': 0.04; '(even': 0.05; 'interpreter': 0.05; 'assigning': 0.09; 'naturally': 0.09; 'returns,': 0.09; 'variables.': 0.09; 'python': 0.11; 'thread': 0.14; 'assigns': 0.16; 'concurrency,': 0.16; 'concurrent': 0.16; 'fine-': 0.16; 'shot.': 0.16; 'subject:recursion': 0.16; 'tuning,': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'work,': 0.20; 'to:name:python- list@python.org': 0.22; 'driver': 0.24; 'received:65.55.116': 0.24; 'subject:problem': 0.24; 'task': 0.26; 'pass': 0.26; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'skip:- 40': 0.29; '[1]': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'libraries': 0.31; 'run': 0.32; 'url:python': 0.33; 'date:': 0.34; 'subject:the': 0.34; 'problem': 0.35; 'but': 0.35; 'there': 0.35; 'accessing': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'method': 0.36; "i'll": 0.36; 'possible': 0.36; 'url:org': 0.36; 'should': 0.36; 'application': 0.37; 'email addr:python.org': 0.37; 'problems': 0.38; 'solving': 0.38; 'tasks': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'does': 0.39; 'subject:': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'url:mail': 0.40; 'how': 0.40; 'even': 0.60; 'easy': 0.60; 'simple': 0.61; 'making': 0.63; 'email addr:gmail.com': 0.63; 're:': 0.63; 'more': 0.64; 'email name:python-list': 0.65; 'due': 0.66; '26,': 0.68; 'overcome': 0.74; 'bounded': 0.84; 'returns.': 0.84; 'careful': 0.91; 'simulation': 0.91; 'task,': 0.91; 'directly.': 0.95; '2013': 0.98 |
| X-TMN | [rmYSv3HSjHLFrOOGyN1jqeUx63Gh9cR6] |
| X-Originating-Email | [carlosnepomuceno@outlook.com] |
| From | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Subject | RE: Solving the problem of mutual recursion |
| Date | Sun, 26 May 2013 21:09:29 +0300 |
| Importance | Normal |
| In-Reply-To | <d54dff54-73cc-4b90-8a85-bafd5118489f@cl9g2000vbb.googlegroups.com> |
| References | <d54dff54-73cc-4b90-8a85-bafd5118489f@cl9g2000vbb.googlegroups.com> |
| Content-Type | text/plain; charset="iso-8859-1" |
| Content-Transfer-Encoding | quoted-printable |
| MIME-Version | 1.0 |
| X-OriginalArrivalTime | 26 May 2013 18:09:29.0445 (UTC) FILETIME=[2A4B7950:01CE5A3C] |
| 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.2185.1369591777.3114.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369591777 news.xs4all.nl 15993 [2001:888:2000:d::a6]:36218 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:46091 |
Show key headers only | View raw
---------------------------------------- > Date: Sun, 26 May 2013 10:21:05 -0700 > Subject: Re: Solving the problem of mutual recursion > From: peter.h.m.brooks@gmail.com > To: python-list@python.org > > On May 26, 5:09 pm, Jussi Piitulainen <jpiit...@ling.helsinki.fi> > wrote: >> >> A light-weighter way is to have each task end by assigning the next >> task and returning, instead of calling the next task directly. When a >> task returns, a driver loop will call the assigned task, which again >> does a bounded amount of work, assigns the next task, and returns. >> Tasks can even pass parameters in the same way. >> > Yes, that's true - there are a number of ways of making it linear. > > What I'm particularly pleased about with my method is the parallelism > that it achieves - with so little effort! The simulation is going to > be computationally intense and this is going to make sure that the > CPUs are all giving it their best shot. When I run this on my macbook, > the python interpreter takes over 140% of CPU - with a bit of fine- > tuning, it should be possible to have more concurrent threads and to > use the four cores optimally. > > Naturally I'll need to be careful with the concurrency, but this is so > simple and clean that it should be easy to avoid the main problems > with accessing the same variables. > -- > http://mail.python.org/mailman/listinfo/python-list Python threads run in the same process and won't run concurrently: "CPython implementation detail: In CPython, due to the Global Interpreter Lock, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). If you want your application to make better use of the computational resources of multi-core machines, you are advised to use multiprocessing. However, threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously."[1] How can you get 140% of CPU? IS that a typo?? [1] http://docs.python.org/2/library/threading.html
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Solving the problem of mutual recursion Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-26 04:49 -0700
Re: Solving the problem of mutual recursion Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-26 18:09 +0300
Re: Solving the problem of mutual recursion Roy Smith <roy@panix.com> - 2013-05-26 11:23 -0400
Re: Solving the problem of mutual recursion Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-26 10:21 -0700
RE: Solving the problem of mutual recursion Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-26 21:09 +0300
Re: Solving the problem of mutual recursion Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-26 11:13 -0700
RE: Solving the problem of mutual recursion Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-26 21:22 +0300
Re: Solving the problem of mutual recursion Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-26 12:05 -0700
Re: Solving the problem of mutual recursion Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-26 13:35 -0600
Re: Solving the problem of mutual recursion Chris Angelico <rosuav@gmail.com> - 2013-05-27 08:16 +1000
Re: Solving the problem of mutual recursion Peter Brooks <peter.h.m.brooks@gmail.com> - 2013-05-26 21:36 -0700
Re: Solving the problem of mutual recursion Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-27 00:07 -0600
Re: Solving the problem of mutual recursion Chris Angelico <rosuav@gmail.com> - 2013-05-27 17:37 +1000
Re: Solving the problem of mutual recursion Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-27 00:19 -0600
Re: Solving the problem of mutual recursion Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-27 01:04 -0600
csiph-web