Open-Source Wikis

/

CPython

/

By the numbers

python/cpython

By the numbers

A quantitative snapshot of the CPython repository.

Data collected on 2026-04-30 against main at commit c80e446e6b9. The repo's first commit dates to August 1990, so the numbers below span 35+ years of history.

Code volume

xychart-beta horizontal
  title "Lines of code by major language (millions)"
  x-axis ["Python (.py)", "RST docs", "C (.c)", "C headers (.h)", "Markdown"]
  y-axis "Million lines" 0 --> 1.2
  bar [1.114, 0.497, 0.662, 0.375, 0.007]
Language Lines Notes
Python (.py) 1,114,631 Standard library, tooling under Tools/, plus an enormous test suite.
C (.c) 661,824 Interpreter, runtime, stdlib accelerators, vendored libs (mimalloc, expat, mpdec, HACL*, libb2).
C headers (.h) 375,200 Include/, Include/cpython/, Include/internal/ and per-module headers.
RST docs 496,846 The book that becomes https://docs.python.org/.
Markdown 7,365 Mostly InternalDocs/ and README.md files.

A large fraction of the C count is generated code that is checked in (so a fresh checkout can build without a working Python). The most prominent examples:

File Lines Generated from
Parser/parser.c 39,432 Grammar/python.gram via Tools/peg_generator/
Python/executor_cases.c.h 23,643 Python/bytecodes.c via Tools/cases_generator/
Python/Python-ast.c 18,465 Parser/Python.asdl via Parser/asdl_c.py
Modules/unicodename_db.h 18,502 UCD data via Tools/unicode/

Source layout

Directory .c files (top-level) .py files (top-level) Role
Python/ 100 Interpreter core, runtime, lifecycle.
Objects/ 50 Built-in types and the object model.
Modules/ 100 C-implemented stdlib modules.
Parser/ 8 Tokenizer, PEG parser, action helpers.
Lib/ 150+ (top level) Pure-Python standard library (incl. nested packages).
Include/ — (284 .h files across Include, Include/cpython, Include/internal) C API surface.

The Lib/test/ subtree alone has 67 nested test packages, totalling over 700 test modules.

Activity

Window Commits Notes
Last year 4,429 Steady ~85/week.
Total 131,150 Since the initial revision in August 1990.
Tagged majors in last 5 years 5 v3.10.0 (Oct 2021) → v3.14.0 (Oct 2025).

Bot-attributed commits (last 12 months)

About 61 of the last 4,429 commits (~1.4%) carry a [bot] co-author or author tag (dependabot[bot], github-actions[bot], the security-update bot, etc.). This is a strict lower bound on automation: it does not capture human-authored commits drafted with assistance, since those leave no trace in git.

Churn hotspots (last 90 days, top 10 by number of commits touching the file)

File Commits
Doc/whatsnew/3.15.rst 87
Python/optimizer_cases.c.h 80
Python/optimizer_bytecodes.c 77
Lib/test/test_capi/test_opt.py 65
Python/bytecodes.c 64
Python/executor_cases.c.h 55
Include/internal/pycore_uop_metadata.h 48
Include/internal/pycore_uop_ids.h 48
Python/generated_cases.c.h 44
Modules/_testinternalcapi/test_cases.c.h 44

Eight of the top ten files relate to the tier 2 / JIT optimizer pipeline — that is the single most active area of CPython today.

Largest source files

File Lines What it is
Parser/parser.c 39,432 Generated PEG parser.
Python/executor_cases.c.h 23,643 Generated tier-2 (uop) dispatch.
Modules/posixmodule.c 18,839 The hand-written posix/os C glue.
Modules/unicodename_db.h 18,502 Unicode names DB (generated from UCD).
Python/Python-ast.c 18,465 Generated AST plumbing.
Objects/unicodeobject.c 15,047 The str implementation.
Lib/pydoc_data/topics.py 14,836 Generated help topics for pydoc.
Modules/clinic/posixmodule.c.h 13,614 Generated Clinic glue for posix.
Python/generated_cases.c.h 13,142 Generated tier-1 dispatch.
Objects/typeobject.c 12,927 The type implementation and method-resolution machinery.

Comments calling for attention

CPython has accumulated about 1,198 TODO/FIXME/XXX/HACK comments across Python/, Objects/, Modules/, and Lib/. The vast majority sit in C extension modules. By contrast the interpreter core (Python/) only contains 19 such markers — the project tends to land or remove rather than annotate.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

By the numbers – CPython wiki | Factory