2
What is your favorite Python syntactic sugar?
(beehaw.org)
Welcome to the Python community on the programming.dev Lemmy instance!
Past
November 2023
October 2023
July 2023
August 2023
September 2023
That's not quite the same as a generator. Iterators require explicit returns to yield control, and this involves dropping the entire stack frame.
True generators allow one to yield, which pauses the function and allows it to be resumed. The most similar thing to this in Rust is an async block/fn, but there is ongoing effort to generalize this so you could create an iterator from a generator.
cool!