Awesome Python - Standard Library

× Home Ask a Dev Python Books Standard Library Hot Repos πŸ”₯ About Github icon
This page is a quick reference for the Python Standard Library. It's highly recommended to get familiar with what comes out-of-the-box with a fresh Python environment!

The The Python Standard Library has many awesome modules
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. β€” 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, pydantic, dacite, pyserde
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, monkeytype
3rd party testing libraries: pytest, parameterized, hypothesis, behave
3rd party coverage libraries: coveragepy, pytest-cov
3rd party style/linting libraries: black, ruff, pylint, flake8, autoflake, isort, pycodestyle, pyflakes, pydocstyle
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.
setuptools, distutils, ensurepip, venv, zipapp
3rd party packaging tools: poetry, pdm, hatch, flit
3rd party standalone executables: pyinstaller, pyOxidizer, py2exe
3rd party venv libraries: pipenv, pipx, pipx comparisons
3rd party package managers: conda, miniconda, mamba, micromamba
Read more: Python Packaging User Guide (PyPUG), Python packaging in 2023
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.