Suspension in a Generator Function

A generator produces values over successive advances, preserving local state between yields when the language supports this model.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace two resumptions
  2. Check when errors arrive

Trace two resumptions

A Python generator can start at three, yield it, increment to four, and yield again on the second advance. The increment after the first yield waits for that next request. Program state traces can mark each suspension.

Check when errors arrive

A malformed source record may fail only as the consumer requests that item. The construction of the generator alone does not exercise it. Iterator exhaustion governs what happens after its work finishes.[1]

References

  1. Python Software Foundation, Functional Programming HOWTO ↩