Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
gottadiveintopython committed Feb 10, 2022
1 parent 1ce1f13 commit 2a2e2bf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions asynckivy/_n_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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()

0 comments on commit 2a2e2bf

Please sign in to comment.