Open-Source Wikis

/

CPython

/

Modules

python/cpython

Modules

Python's standard library is split between pure Python code under Lib/ and C extension modules under Modules/. This section is an orientation guide to both.

The boundary is documented per-module by InternalDocs/structure.md: for a module foo, the typical layout is Lib/foo.py + (if there's a C accelerator) Modules/_foo.c + Lib/test/test_foo.py + Doc/library/foo.rst.

Page Covers
Python standard library The pure-Python half of the stdlib: organisation, conventions, packages.
C extension modules The C-implemented stdlib modules in Modules/.

Where built-in things live

You're looking for Location
The os module Lib/os.py (Python) + Modules/posixmodule.c (os is mostly posix re-exported)
The sys module Python/sysmodule.c (built into the interpreter)
builtins Python/bltinmodule.c
marshal Python/marshal.c
gc Modules/gcmodule.c
_thread Modules/_threadmodule.c
asyncio Lib/asyncio/ + Modules/_asynciomodule.c
re Lib/re/ + Modules/_sre/
json Lib/json/ + Modules/_json.c
decimal Lib/decimal.py (re-exports _decimal) + Modules/_decimal/ (libmpdec) + Lib/_pydecimal.py (pure-Python fallback)
io Lib/io.py + Modules/_io/ + Lib/_pyio.py
pickle Lib/pickle.py + Modules/_pickle.c
datetime Lib/datetime.py (re-exports _datetime) + Modules/_datetimemodule.c + Lib/_pydatetime.py
Built-in types' int/str/dict Objects/ — see Object model

builtins, sys, marshal, _thread, gc, _io, _imp, posix (nt on Windows), _warnings, errno, _signal, _codecs are statically linked into the interpreter and listed in _PyImport_Inittab in Python/import.c. Everything else is a .so / .pyd built by the standard CPython build.

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

Modules – CPython wiki | Factory