Programming Linux
Quick search
Navigation
Courses
Courses Overview
Slide Material
Python Programming
Python: The Language Fundamentals
Python: More Language Features
Comprehensions (List, Dictionary, Set)
Exception Handling
Iterating Intelligently: Generators, and the Iterator Protocol
Iteration, Comprehensions, and Generators
Iteration, Generators, And
yield
Positional and Keyword Arguments
Closures
Decorators
Context Managers: The
with
Statement
The
exec()
Function
Object Oriented Programming
Modules and Packages
Multithreading
Python: Project/Package Management
Python: Miscellaneous Topics
Python: Draft Topics
Python Links
Python: All Material, Interrelated
Exercises
The C Programming Language
C++: TODO List
C++: Miscellaneous Live-Hacking
C++
The New C++ (11-…)
Design Patterns With C++
C++ Code
C++ Exercises
CMake
Linux
Is Software A Craft? Software Is A Craft! ⟶
Clean Code
Unit Testing With
googletest
Linux Kernel Driver Development
Generated Topic Graph
How To Book
Log Of Past Courses
About
Myself: Contact, Impressum, …
This Site
Blog
Posts
Iterating Intelligently: Generators, and the Iterator Protocol
¶
Iteration, Comprehensions, and Generators
Coverage Of This Topic
for
Recap:
Sequential Datatypes
Primitive Transformation
[1,2,3,4]
⟶
[1,4,9,16]
List Comprehension
Larger Input List (Still
Allocated
)
Input List ⟶
range
Output List ⟶
yield
Generator Function ⟶
Generator Expression
Iteration, Generators, And
yield
The Iterator Protocol
Iteration in Python
What’s an Iterator?
What’s an Iterable?
The Iterator Protocol
The Iterator Protocol: Manual Iteration
The Iterator Protocol, And The
for
Loop
Generators: Motivation
Generators: How?
Observations
Implementing A Fibonacci Number Generator
Fibonacci Numbers: Naive List
Fibonacci Numbers: Naive List, Limited
Sideway: Infinity by Not Using Functions
Fibonacci Numbers: Function Producing Infinite Sequence
Common Pattern: Turn List into Generated Items