Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95602
| Path | csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'context': 0.05; 'column': 0.07; 'e.g.,': 0.07; 'extends': 0.07; 'concurrent': 0.09; 'executes': 0.09; 'implies': 0.09; 'modules.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'vast': 0.09; 'example:': 0.10; 'thread': 0.10; 'python': 0.10; '<>.': 0.11; 'appropriate': 0.14; 'suggest': 0.15; '(and,': 0.16; "(it's": 0.16; 'bytecode': 0.16; 'concurrency': 0.16; 'coroutines': 0.16; 'executed,': 0.16; 'headings': 0.16; 'jython,': 0.16; 'otoh,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:etc.': 0.16; 'sure.': 0.16; 'task.': 0.16; 'thread.': 0.16; 'threading': 0.16; 'threading,': 0.16; 'extension': 0.20; 'suggested': 0.20; 'code.': 0.23; 'seems': 0.23; "haven't": 0.24; 'patch': 0.24; 'module': 0.25; 'header :User-Agent:1': 0.26; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'helpful': 0.27; '(e.g.,': 0.27; '(it': 0.29; '(used': 0.29; 'another.': 0.29; 'blocking': 0.29; 'gil': 0.29; 'i/o': 0.29; "i'm": 0.30; 'code': 0.30; 'anybody': 0.32; 'run': 0.33; 'useful': 0.33; 'url:python': 0.33; 'machine.': 0.33; 'message- id:@gmail.com': 0.34; 'correctly': 0.34; 'structure': 0.34; 'skip:c 30': 0.35; 'execution': 0.35; 'tasks': 0.35; 'quite': 0.35; 'comment': 0.35; 'supports': 0.35; 'but': 0.36; 'instead': 0.36; 'there': 0.36; 'url:org': 0.36; 'faster': 0.36; 'modules': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'being': 0.37; 'expect': 0.37; 'say': 0.37; 'received:org': 0.37; 'requirement': 0.37; 'someone': 0.38; 'sure': 0.39; 'application': 0.39; 'resources': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'url:3': 0.60; 'your': 0.60; 'confirm': 0.62; 'more': 0.63; 'due': 0.65; 'subject:. ': 0.67; 'received:89': 0.80; 'awaited': 0.84; 'choices,': 0.84; 'gap': 0.84; 'mistaken': 0.84; 'remarks': 0.84; 'top.': 0.84; 'execution,': 0.91; 'cooperative': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Akira Li <4kir4.1i@gmail.com> |
| Subject | Re: asyncio, coroutines, etc. and simultaneous execution |
| Date | Mon, 24 Aug 2015 02:28:38 +0300 |
| References | <55DA3E96.6090703@earthlink.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| X-Gmane-NNTP-Posting-Host | 89.169.229.68 |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| Cancel-Lock | sha1:Sg6PUFhqpSG2cga4wr0G7tm5Hl8= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.0.1440372631.11709.python-list@python.org> (permalink) |
| Lines | 70 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1440372631 news.xs4all.nl 23854 [2001:888:2000:d::a6]:36131 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:95602 |
Show key headers only | View raw
Charles Hixson <charleshixsn@earthlink.net> writes: > If I understand correctly asyncio, coroutines, etc. (and, of course, > Threads) are not simultaneously executed, and that if one wants that > one must still use multiprocessing. But I'm not sure. The note is > still there at the start of threading, so I'm pretty sure about that > one. Due to GIL (used by CPython, Pypy, not used by Jython, IronPython, pypy-stm) only one thread executes Python bytecode at a time. GIL can be released on I/O or in a C extension such as numpy, lxml, regex. It is true for any Python module or concept you use. Unrelated: use concurrent and parallel execution instead of "simultaneously executed." Parallelism might make a program faster (it implies that hardware supports it). Concurrency is a way to structure the code. The same concurrent program can run in parallel and without parallelism. Recommended: "Concurrency is not Parallelism (it's better!)" talk by Rob Pike's talk http://stackoverflow.com/questions/1050222/concurrency-vs-parallelism-what-is-the-difference > The requirement that coroutines always be awaited seems to confirm > this, but doesn't really say so explicitly. And the concurrent.futures > can clearly be either, depending on your choices, but the chart in > 18.5.3.1.3 Example: Chain coroutines is of a kind that I am more > familiar with in the context of multiprocessing. (E.g., the only gap > in the chart, which extends across all headings is when a result is > being waited for during a sleep.) For threaded execution I would > expect there to be a gap whenever processing is shifted from one > column to another. > > If someone has authority to edit the documentation a comment like: Anybody can suggest a patch https://docs.python.org/devguide/docquality.html > If you want your application to make better use of the computational > resources of multi-core machines, you are advised to use > multiprocessing > <https://docs.python.org/3.5/library/multiprocessing.html#module-multiprocessing> > or concurrent.futures.ProcessPoolExecutor > <https://docs.python.org/3.5/library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor>. However, > threading is still an appropriate model if you want to run multiple > I/O-bound tasks simultaneously. > > (to quote from the threading documentation) would be helpful at or > very near the top of each of the appropriate modules. It would also > be useful if the modules that were definitely intended to result in > simultaneous execution, when feasible, were so marked quite near the > top. It is not necessary that multiprocessing will make your code faster on a multi-core machine. It may make it slower depending on the task. Performance optimization is a vast topic. Short remarks such as you've suggested are likely misleading. > OTOH, I may be mistaken about coroutines. I haven't been able to tell. Many cooperative multitasking implementations use a *single* thread. There is a way to offload blocking code e.g., loop.run_in_executor() in asyncio.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: asyncio, coroutines, etc. and simultaneous execution Akira Li <4kir4.1i@gmail.com> - 2015-08-24 02:28 +0300
csiph-web