On Wed, Mar 25, 2020 at 10:08 AM Dan Stromberg <drsali...@gmail.com> wrote:
>
> Some time ago, when I first heard about yield from, it wasn't faster than a
> for loop yielding.
>
> Has that improved?

It's not about speed. It's about correctness, and the way it delegates
everything, not just "for x in iter: yield x". Here's what it's
actually equivalent to:

https://www.python.org/dev/peps/pep-0380/#formal-semantics

It'll be a LOT more efficient than writing all that out manually. For
the simple case where you really can just loop and yield, sure, though
IMO it's still clearer to yield-from than to loop-yield.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list
  • yield from Dan Stromberg
    • Re: yield from Chris Angelico

Reply via email to