{
  "id": "python-timeit-table",
  "kind": "table",
  "slug": "python-timeit",
  "iil_id": null,
  "note_url": "https://iinventedlight.com/library/notes/python-timeit/",
  "title": "Python timeit times small snippets from the command line or code, avoiding common timing traps",
  "columns": [
    "name",
    "source",
    "detail"
  ],
  "rows": [
    {
      "name": "-n N",
      "source": "Python docs",
      "detail": "sets how many times to execute the statement. Without -n, timeit tries increasing loop numbers until the total time is at least --target-time (default: 0.2 seconds)."
    },
    {
      "name": "-r N",
      "source": "Python docs",
      "detail": "sets how many times to repeat the timer (default 5)."
    },
    {
      "name": "-s S",
      "source": "Python docs",
      "detail": "gives a setup statement executed once initially."
    },
    {
      "name": "-p",
      "source": "Python docs",
      "detail": "measures process time, not wallclock time."
    },
    {
      "name": "timeit()",
      "source": "Python docs",
      "detail": "determines the number of repetitions automatically only in the command-line interface; the Python function defaults to number=1000000."
    }
  ],
  "related_slugs": [
    "python-functools",
    "python-itertools",
    "python-unittest"
  ],
  "license": "CC-BY-4.0",
  "source_license": "PSF-2.0 (Python docs); PSF-2.0 (python/cpython (GitHub)); prose restates cited source lines in own words",
  "as_of": "2026-11-18",
  "status": "fill-draft-20261118",
  "note": "Restated from the note's GREEN sources; check those sources before relying on a value."
}