The Python Standard Library

Selected summary of The Python Standard Library that is distributed with Python
Also see The Python Language Reference for the “core semantics” of the language and Python Enhancement Proposals (PEPs)

Core LibraryModules
Built-ins The principal built-in types are functions, constants, exceptions, numerics, sequences, mappings, classes and instances.
Built-in Functions - Built-in Constants - Built-in Exceptions
Built-in Types:
int, float, complex, list, tuple, range, str
bytes, bytearray, memoryview, set, frozenset, dict
Type Annotations: Generic Alias, Union, Other built-in types
Specialized Data Types Specialized data types such as dates and times, fixed-type arrays, heap queues, double-ended queues, and enumerations.
datetime, zoneinfo, calendar, array, heapq, enum, pprint
collections — Specialized containers; alternatives to dict, list, set, and tuple.
collections.abc — Test class interfaces; e.g. hashable or is a mapping.
bisect — Maintaining a sorted list after each insertion using array bisection
weakref — Weak object reference allowing garbage collection
types — Dynamic type creation and names for built-in types
copy — Shallow and deep copy operations
reprlib — Object representations with string size limits
graphlib — Functionality to topologically sort a graph
3rd party datetime libraries: arrow, pendulum
Text Processing String manipulation operations and other text processing services.
string, re, difflib, textwrap, unicodedata, stringprep, readline, rlcompleter
3rd party text libraries: transformers, spacy, gensim, nltk
Binary Data Basic services operations for manipulation of binary data
struct, codecs
3rd party binary libraries: h5py, pyarrow, avro, fastparquet
Numeric and Mathematical The numbers module defines an abstract hierarchy of numeric types.
The math and cmath modules contain mathematical functions for floating-point and complex numbers.
The decimal module supports exact representations of decimal numbers, using arbitrary precision arithmetic.
numbers, math, cmath, decimal, fractions, random, statistics
3rd party math libraries: numpy, sympy, scipy, scikit-learn, tensorflow, pytorch
Functional Programming Classes that support a functional programming style, and general operations on callables.
itertools — Functions creating iterators for efficient looping
functools — Higher-order functions and operations on callable objects
operator — Standard operators as functions
3rd party functional libraries: toolz, funcy, wrapt, more-itertools
Concurrent Execution Concurrent execution of code.
threading — Thread-based parallelism
multiprocessing — Process-based parallelism
multiprocessing.shared_memory — Provides shared memory for direct access across processes
concurrent.futures — Launching parallel tasks
subprocess — Subprocess management
sched — Event scheduler
queue — A synchronized queue class
contextvars — Context Variables
_thread — Low-level threading API
3rd party (distributed) concurrency libraries: dask, dask.distributed, celery
Networking and Interprocess Networking and inter-processes communication.
Some modules only work for two processes that are on the same machine, e.g. signal and mmap.
Other modules support networking protocols that two or more processes can use to communicate across machines.
asyncio — Asynchronous I/O
socket — Low-level networking interface
ssl — TLS/SSL wrapper for socket objects
select — Waiting for I/O completion
selectors — High-level I/O multiplexing
signal — Set handlers for asynchronous events
mmap — Memory-mapped file support
3rd party asyncio libraries: uvloop, trio, curio, anyio, asyncer
Data Serialization and Persistence Serialization and persisting data to disk.
pickle, copyreg, shelve, marshal, dbm, sqlite3
3rd party serialization libraries: flatbuffers, dataclasses-json, marshmallow
3rd party data-storage libraries: aws-data-wrangler, pandas, modin, vaex, xarray, pytables
3rd party sql libraries: sqlalchemy, alembic, sqlmodel, sqlite-utils
Operating System Services OS features, such as files, datetime, argument parsing, logging etc.
os, io, time, argparse, getopt, logging, getpass, curses, platform, errno, ctypes
3rd party argparse libraries: click, python-fire, typer
3rd party logging/env/C++ libraries: loguru, python-dotenv, pybind11
Graphical User Interfaces tkinter is fast and usually comes bundled with Python.
3rd party GUI libraries: PySimpleGUI, DearPyGui, remi, pygame, panda3d, arcade
File and Directory Access Disk files and directories.
pathlib, os.path, fileinput, stat, filecmp, tempfile, glob, fnmatch, linecache, shutil
3rd party functional libraries: pyfilesystem2
Data Compression Data compression with the zlib, gzip, bzip2 and lzma algorithms, and the creation of zip and tar archives.
zlib, gzip, bz2, lzma, zipfile, tarfile
File Formats Miscellaneous file formats that aren't markup languages and are not related to e-mail.
csv, configparser, netrc, plistlib
3rd party file-format libraries: XlsxWriter, imageio, markdown (see also 3rd party binary libraries)
Cryptographic Services Cryptographic algorithms; available at the discretion of the installation.
hashlib, hmac, secrets
3rd party cryptographic libraries: cryptography, pynacl, bcrypt
Internet Data Handling email, json, mailbox, mimetypes, base64, binhex, binascii, quopri.
Structured Markup html and xml.
Internet Protocols and Support webbrowser, wsgiref, urllib, http, ftplib, poplib, imaplib, smtplib, uuid, socketserver, xmlrpc, ipaddress etc.
3rd party internet libraries: requests, TODO: more
Dev, Packaging and Runtime
Development Tools Modules to help you write software
typing — Support for type hints
pydoc — Documentation generator and online help system
doctest — Test interactive Python examples
unittest — Unit testing framework
unittest.mock — mock object library
unittest.mock — getting started
test — Regression tests package for Python (internal)
Python Development Mode
3rd party typing libraries: mypy, pyright, pyre-check, pytype
3rd party testing libraries: pytest, parameterized, hypothesis, behave
3rd party coverage libraries: coveragepy, pytest-cov
3rd party style libraries: pylint, flake8, isort, pycodestyle, pyflakes, pydocstyle, pytest
3rd party doc libraries: mkdocs-material, sphinx, readthedocs
Debugging and Profiling The debugger enables you to step through code, analyze stack frames and set breakpoints etc
Profilers run code and give you a detailed breakdown of execution times, allowing you to identify bottlenecks
Auditing events provide visibility into runtime behaviors that would otherwise require intrusive debugging or patching
bdb — Debugger framework
faulthandler — Dump the Python traceback
pdb — The Python Debugger
timeit — Measure execution time of small code snippets
trace — Trace or track Python statement execution
tracemalloc — Trace memory allocations
Audit events table
The Python Profilers
3rd party debugging libraries: PySnooper, icecream, snoop, birdseye
3rd party profiling libraries: memray, viztracer, pyheat
Software Packaging and Distribution These libraries help you with publishing and installing Python software.
distutils, ensurepip, venv, zipapp
3rd party packaging libraries: pyinstaller, pyOxidizer
3rd party venv libraries: poetry, pipenv, pipx
3rd party package managers: conda, miniconda, mamba, micromamba
Python Runtime Services related to the Python interpreter and its interaction with its environment.
__main__ — Top-level code environment
__future__ — Future statement definitions
sys — System-specific parameters and functions
sysconfig — Provide access to Python’s configuration information
builtins — Built-in objects
warnings — Warning control
dataclasses — Data Classes: mutable namedtuples with defaults
contextlib — Utilities for with-statement contexts
abc — Abstract Base Classes
atexit — Exit handlers
traceback — Print or retrieve a stack traceback
gc — Garbage Collector interface
inspect — Inspect live objects
site — Site-specific configuration hook
3rd party libraries: pydantic
Runtime/compilation alternatives: CPython, Cython, PyPy, CPython without the GIL, numba
Importing ModulesModules that provide new ways to import Python modules and hooks for customizing the import process.
Python LanguageThese modules support tokenizing, parsing, syntax analysis, bytecode disassembly etc.
Back to Awesome Python