Path: csiph.com!eternal-september.org!feeder.eternal-september.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!87.79.20.101.MISMATCH!newsreader4.netcologne.de!news.netcologne.de!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: 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; 'python,': 0.02; 'startup': 0.05; 'that?': 0.05; '(especially': 0.07; 'algorithms,': 0.07; 'computing,': 0.07; 'core,': 0.09; 'definition,': 0.09; 'meaningful': 0.09; 'message-id:@4ax.com': 0.09; 'non-blocking': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thread': 0.10; 'python': 0.10; 'interpreter': 0.15; '(and,': 0.16; 'amiga': 0.16; 'bound)': 0.16; 'chip': 0.16; 'executed,': 0.16; 'gil,': 0.16; 'gil.': 0.16; 'line)': 0.16; 'processors': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:etc.': 0.16; 'sure.': 0.16; 'threading,': 0.16; 'threads': 0.16; 'later': 0.16; 'memory': 0.17; 'found,': 0.18; 'processor': 0.18; 'url:home': 0.18; 'library': 0.20; '2015': 0.20; 'aug': 0.20; 'affects': 0.22; '(or': 0.23; 'transfers': 0.23; 'somewhere': 0.24; 'module': 0.25; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'question': 0.27; 'fine': 0.28; '(it': 0.29; '-0700,': 0.29; 'blocking': 0.29; 'chase': 0.29; 'closer': 0.29; 'gil': 0.29; 'i/o': 0.29; 'objects': 0.29; "i'm": 0.30; 'becomes': 0.30; 'another': 0.32; "can't": 0.32; 'core': 0.32; 'common': 0.33; 'flags': 0.33; 'ram': 0.33; 'correctly': 0.34; 'handle': 0.34; 'could': 0.35; 'execution': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; '(and': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'two': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'things': 0.38; 'creation': 0.38; 'shared': 0.38; 'speak': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'still': 0.40; 'collection': 0.60; 'digital': 0.63; 'more': 0.63; 'different': 0.63; 'sharing': 0.64; 'between': 0.65; 'rare': 0.66; 'remember,': 0.66; 'subject:. ': 0.67; 'banks': 0.72; '>if': 0.84; 'process...': 0.84; 'processor.': 0.84; 'routines': 0.84; 'trades': 0.84; 'banks,': 0.91; 'dennis': 0.91; 'interrupt': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: asyncio, coroutines, etc. and simultaneous execution Date: Sun, 23 Aug 2015 18:26:54 -0400 Organization: IISS Elusive Unicorn References: <55DA3E96.6090703@earthlink.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-68-178-61.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1440368823 news.xs4all.nl 23751 [2001:888:2000:d::a6]:57710 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95601 On Sun, 23 Aug 2015 14:43:50 -0700, Charles Hixson declaimed the following: >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. > Is there a question somewhere in all that? Coroutines, by classic definition, are routines that cooperate in switching off execution -- remember, for half the existence of electronic digital computing, something like a multi-core computer was very rare (vectorized super-computers, et al). Where multiple processors were found, they were not general purpose... The Sigma-6 (and most of the SDS/XDS Sigma line) had the main "computer" and a collection of SIOP and MIOP to handle I/O transfers from between memory and peripherals (it also had a 4-bank, 4-port interleaved memory so the IOPs and main processor could chase each other without wait states; the Amiga had two banks, but only CHIP RAM was 2-port, and the banks were not interleaved, so CHIP access could block main processor) In common Python, the GIL affects things like number crunching (CPU bound) algorithms, in that only the thread holding the GIL can perform meaningful work -- so a thread in another core, not holding the GIL, is blocked. Nothing different than a single core processor. But I/O bound algorithms -- since the I/O library releases the GIL before blocking on system I/O calls -- work fine with GIL and multiple cores. The multiprocessing module trades off the fast creation of threads limited by the GIL for slower process startup (especially on Windows) by giving each process its own, well, system process and Python interpreter with its own GIL. But sharing state between these processes becomes more complex -- you don't really have shared global objects that can be tested. Can't speak for asyncio -- my mind just doesn't work that way. For asynchronous I/O, threads/Queue work for me (or VMS style non-blocking QIO with event flags that can be tested and waited for later in the process... ASTs if one wants something that behaves closer to an interrupt handler). -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/