Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Mod : Example 16-17 grouper optimization #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions 16-coroutine/coroaverager3.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ def averager(): # <1>

# the delegating generator
def grouper(results, key): # <5>
while True: # <6>
results[key] = yield from averager() # <7>
# while True: # <6>
results[key] = yield from averager() # <7>
# When group.send(None) is called, group runs to the yield statement below
# without raising StopIteration and creating a useless new instance of averager
yield


# the client code, a.k.a. the caller
Expand Down