you might be wondering"what does this have to do with object-oriented programmingthere isn' even one class in this code!in some waysyou' be rightneither coroutines nor generators are commonly considered object-oriented howeverthe functions that create them return objectsin factyou could think of those functions as constructors the constructed object has appropriate send(and __next__(methods basicallythe coroutine/generator syntax is syntax shortcut for particular kind of object that would be quite verbose to create without it this case study has been an exercise in bottom-up design we created various lowlevel objects that did specific tasks and hooked them all together at the end find this to be common practice when developing with coroutines the alternativetopdown design sometimes results in more monolithic pieces of code instead of unique individual pieces in generalwe want to find happy medium between methods that are too large and methods that are too small and it' hard to see how they fit together this is trueof courseregardless of whether the iterator protocol is being used as we did here exercises if you don' use comprehensions in your daily coding very oftenthe first thing you should do is search through some existing code and find some for loops see if any of them can be trivially converted to generator expression or listsetor dictionary comprehension test the claim that list comprehensions are faster than for loops this can be done with the built-in timeit module use the help documentation for the timeit timeit function to find out how to use it basicallywrite two functions that do the same thingone using list comprehensionand one using for loop pass each function into timeit timeitand compare the results if you're feeling adventurouscompare generators and generator expressions as well testing code using timeit can become addictiveso bear in mind that code does not need to be hyperfast unless it' being executed an immense number of timessuch as on huge input list or file play around with generator functions start with basic iterators that require multiple values (mathematical sequences are canonical examplesthe fibonacci sequence is overused if you can' think of anything bettertry some more advanced generators that do things like take multiple input lists and somehow yield values that merge them generators can also be used on filescan you write simple generator that shows those lines that are identical in two files