From 2a2e2bf42d6fc85741bead3444242ecc66faeee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natt=C5=8Dsai=20Mit=C5=8D?= Date: Thu, 10 Feb 2022 20:44:46 +0900 Subject: [PATCH] optimize --- asynckivy/_n_frames.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/asynckivy/_n_frames.py b/asynckivy/_n_frames.py index 3dc3da4..c6aab41 100644 --- a/asynckivy/_n_frames.py +++ b/asynckivy/_n_frames.py @@ -19,7 +19,7 @@ def _resume(dt): @types.coroutine -def one_frame(): +def one_frame(*, _trigger_resume=_trigger_resume): # default引數を使った最適化を試してみる '''(experimental) wait for one frame. @@ -37,7 +37,7 @@ async def async_fn(): yield _waiting.append -async def n_frames(n: int): +async def n_frames(n: int, *, _one_frame=one_frame, _range=range): # default引數を使った最適化を試してみる '''(experimental) wait for the specified number of frames. @@ -53,6 +53,5 @@ async def async_fn(): ''' if n < 0: raise ValueError("Cannot wait for negative number of frames") - _one_frame = one_frame - for __ in range(n): + for __ in _range(n): await _one_frame()