Importantly, the main benefit of
yield from
(allowing
send
to delegate to the subgenerator instead of being received by the wrapping generator; the reason it was created in the first place, rather than just telling programmers to explicitly
yield
each item like the OP was doing in the first place) is lost when you wrap in
map
, so there is little benefit to using
yield from
over just returning the
map
unless you have some other values to
yield
before or after (where a single return wouldn't work without additional, and somewhat costly, wrapping, e.g. via
itertools.chain
). —
ShadowRanger 24 secs ago