Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: [Python-ideas] How the heck does async/await work in Python 3.5 Date: Wed, 24 Feb 2016 09:47:41 -0700 Lines: 41 Message-ID: References: <56c7d145$0$1597$c3e8da3$5496439d@news.astraweb.com> <56CCC98C.5060504@mail.de> <87vb5ejfnv.fsf@elektro.pacujo.net> <87r3g2jdcb.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de I0Sp1cX9qunodUpJzd16xwWU3tJHJERTlqGvU87Fs7NA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'subject:How': 0.09; 'def': 0.13; 'wed,': 0.15; 'skip:p 40': 0.15; '2016': 0.16; '24,': 0.16; '9:13': 0.16; 'data)': 0.16; 'reasonable.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:ideas': 0.16; 'write.': 0.16; 'wrote:': 0.16; 'skip:l 30': 0.18; 'subject:] ': 0.19; '>>>': 0.20; 'work,': 0.21; 'am,': 0.23; 'feb': 0.23; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'point.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:/': 0.30; "i'd": 0.31; 'skip:_ 10': 0.32; 'point': 0.33; 'class': 0.33; 'curious': 0.33; 'received:google.com': 0.35; 'quite': 0.35; 'something': 0.35; "isn't": 0.35; 'there': 0.36; 'received:209.85': 0.36; 'subject:work': 0.36; 'to:addr:python- list': 0.36; 'missing': 0.37; 'seem': 0.37; 'received:209': 0.38; 'wrong': 0.38; 'anything': 0.38; 'test': 0.39; 'subject:the': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'ever': 0.60; 'skip:u 10': 0.61; '20,': 0.66; 'benchmark': 0.84; 'influencing': 0.84; 'tem': 0.84; 'to:name:python': 0.84; 'urge': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=4zSCwUtFXnRX4L/89NtEXNFMnic+HvugFaIhGNtKOrU=; b=vHCooFREr+EOMKvzdtYGVbZu2jdqLfzsDnZfZcuN2DrKN/rzcB8t7Q4aiiBHOQPgzn RbakD7tq0FctjE8aukZ1D3lA4ggs2zJGEWrvcYBvVjgLeY5UjTgA9+fnnPleog+DcFg8 oaptUcwCuj/YQUm+OjPZ5jR6UKD0DlwcEs7d7xk9A87P5JAgztqpwXoIJHmqPQ3G0w8L +fXyPrSddD9qvBGRvCeYySaNeqxM0lQVg/UgzM54olXVQ2DHmDzb6t4y6TI1yniEubvQ 6HNzPcy1PXumJXmLCpm74xHujUKOmzSFynhoiZN9pcAGdabmxS1zw31xPTaGKNf93AId uerQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=4zSCwUtFXnRX4L/89NtEXNFMnic+HvugFaIhGNtKOrU=; b=inkZ3byYi/zZAcgzi+E+r6Qg5+awRcPM6DkBYtdJbT4OLTJs3ic5M+37yVzrx5zfSW ZfqiGRB+m1ysYuMK8KiKsiqzph8Ph4RIiDlH977fa4Q2bufjJ3ACdydGr5wTo9pI1aUx QnIW9YUPsXIi+A8jlNR9vQrrm8/Zmj88QTYmBfca7LH5F0/sdVb5//7u40tBXTombdzu i4BVb22BkMWqOLwITDaKZvtoiKtlTHf/MpQjWPayjfldHeVc10MzhDpCrCT7BzGLsDpz dcnMD2vajn1lb9Xexl1/GBIBirvYzfvw+aT0Pif5IX0COINRLh2z0v5LhQkbW7c6yAVS aIJg== X-Gm-Message-State: AG10YOQDFB5jJwZPVVGAwo35NHRG0kXbMvrywhcyqGxTWpAFyx1m5J0CWebuD+8wnF5tEimdkSpJ3ORqN2pACA== X-Received: by 10.107.19.90 with SMTP id b87mr44267807ioj.11.1456332500511; Wed, 24 Feb 2016 08:48:20 -0800 (PST) In-Reply-To: <87r3g2jdcb.fsf@elektro.pacujo.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103454 On Wed, Feb 24, 2016 at 9:13 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote: >>> Tem Pl : >>>> Is there something wrong with this implementation? >>> >>> It's a "fork bomb". >> >> Isn't that the point of the benchmark? > > I don't quite see the point of the program as it doesn't resemble > anything I'd ever have an urge to write. That's reasonable. asyncio is designed for I/O-bound work, so a fair response to the benchmark is that subjecting it to a CPU-bound stress test is perhaps missing the point. I was curious about how much the selector-based event loop might be influencing the timing, so I tried instrumenting the selector. class ProfiledSelector(selectors.DefaultSelector): def __init__(self): super().__init__() self._calls = collections.Counter() def select(self, timeout=None): self._calls['select'] += 1 return super().select(timeout) def register(self, fileobj, events, data=None): self._calls['register'] += 1 return super().register(fileobj, events, data) selector = ProfiledSelector() loop = asyncio.SelectorEventLoop(selector) asyncio.set_event_loop(loop) loop.run_until_complete(coroutine()) # 499999500000 selector._calls # Counter({'select': 20, 'register': 1}) Only 20 iterations of the event loop? That doesn't seem unreasonable.