/PyCon

Repo containing draft materials for pysangamam and pycon talk proposal

Primary LanguageHTML

Generators explained

Target audience

Beginners who are familiar with the basics of python. Exposure to basic concepts like iteration using for loops and while loops are required. Knowledge of classes will help.

Objective

To gain a conceptual understanding of how python generators work, and how to use them to make your code more efficient and sleek.

Outline

  • What are generators? (~5 min)
    • Introduction to standard iteration
    • Iteration using generator functions
      • Infinite series
  • Generators in practice - data loading in machine learning (~3 min)
  • How do they work? (~7 min)
    • Sending data back into generators
      • Example - Running metric evaluation
    • Stacking generators and the yield from statement
      • Example - binary tree traversal
  • A brief foray into async and co-routines (~5 min)
    • Understanding yield from
    • A simple example of an event loop