Lazy evaluation in Python
By Rahul Pydimukkala (rahulpyd@gmail.com)
BangPypers meetup (18th
Feb.,2017)
Lazy evaluation in Python
What is lazy evaluation?
Lazy evaluation in Python
Delay the evaluation
of an expression
until its value is needed.
Lazy evaluation in Python
Why?
- Enables infinite data structures
- Control structures as abstractions
- Performance benefits – computational and space
Lazy evaluation in Python
Why infinite data structures?
Lazy sequences
Lazy evaluation in Python
Abstracting out control structures
Lazy evaluation in Python
Generators
Lazy evaluation in Python
Generator expressions (genexps)
Lazy evaluation in Python
Iterator protocol
Iterator object
Iterables

Lazy evaluation in Python