]> granicus.if.org Git - python/commitdiff
bpo-32351: Use fastpath in asyncio.sleep if delay<0 (#4908)
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Sun, 17 Dec 2017 14:41:30 +0000 (16:41 +0200)
committerGitHub <noreply@github.com>
Sun, 17 Dec 2017 14:41:30 +0000 (16:41 +0200)
* Use fastpath in asyncio.sleep if delay<0

* Add NEWS entry

Lib/asyncio/tasks.py
Misc/NEWS.d/next/Library/2017-12-17-14-23-23.bpo-32351.95fh2K.rst [new file with mode: 0644]

index cdb483ae0eb2da23f25113e0253e345d1b7f5a41..275141c65e7e224edbd61a9f5fc26d4882452db3 100644 (file)
@@ -503,7 +503,7 @@ def __sleep0():
 
 async def sleep(delay, result=None, *, loop=None):
     """Coroutine that completes after a given time (in seconds)."""
-    if delay == 0:
+    if delay <= 0:
         await __sleep0()
         return result
 
diff --git a/Misc/NEWS.d/next/Library/2017-12-17-14-23-23.bpo-32351.95fh2K.rst b/Misc/NEWS.d/next/Library/2017-12-17-14-23-23.bpo-32351.95fh2K.rst
new file mode 100644 (file)
index 0000000..56f52d2
--- /dev/null
@@ -0,0 +1 @@
+Use fastpath in asyncio.sleep if delay<0 (2x boost)