{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ch12-title",
   "metadata": {},
   "source": [
    "# Iterators & Generators"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch12-overview",
   "metadata": {},
   "source": [
    "Iterators and generators are the backbone of Python's memory-efficient data processing.\n",
    "\n",
    "- The iterator protocol: `__iter__` and `__next__`\n",
    "- Built-in lazy iterators\n",
    "- Custom iterator classes\n",
    "- Generator functions and generator expressions\n",
    "- Lazy pipelines for streaming data\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1200-video",
   "metadata": {},
   "source": [
    "<h2>Video</h2>\n",
    "\n",
    "This overview introduces generator functions and lazy value production with yield.\n",
    "\n",
    "```{raw} html\n",
    "<iframe width=\"100%\" height=\"400\" src=\"https://www.youtube-nocookie.com/embed/bD05uGo_sVI\" title=\"Python Tutorial: Generators - How to use them and the benefits you receive\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen referrerpolicy=\"strict-origin-when-cross-origin\"></iframe>\n",
    "```\n",
    "\n",
    "> *[Python Tutorial: Generators - How to use them and the benefits you receive](https://youtube.com/watch?v=bD05uGo_sVI) by Corey Schafer*"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch12-goals",
   "metadata": {},
   "source": [
    "<h2>Learning Goals</h2>\n",
    "\n",
    "By the end of this chapter, you will be able to:\n",
    "\n",
    "1. Explain Python's iterator protocol and use `iter()` and `next()` manually\n",
    "2. Use built-in lazy iterators such as `enumerate()`, `zip()`, `map()`, `filter()`, and `reversed()`\n",
    "3. Build custom iterator classes that implement the iterator protocol\n",
    "4. Write generator functions with `yield`\n",
    "5. Design multi-step data pipelines using chained generators\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ch12-flow",
   "metadata": {},
   "source": [
    "<h2>Chapter Flow</h2>\n",
    "\n",
    "```{tableofcontents}\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1200-slides",
   "metadata": {},
   "source": [
    "<h2><a href=\"overview.html\" target=\"_blank\" style=\"color: var(--pst-color-link, #176de8);\">Chapter Overview Slides</a></h2>"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
