Python standard library¶
See also Supported platforms and architectures, History of Python, and Python Import.
sys.stdlib_module_names¶
Python 3.14: 290 modules
Add (1):
annotationlib
Python 3.13: 289 modules
Add (10):
Remove (21), PEP 594:
_crypt
,_msi
,aifc
,audioop
,cgi
,cgitb
,chunk
,crypt
,imghdr
,mailcap
,msilib
,nis
,nntplib
,ossaudiodev
,pipes
,sndhdr
,spwd
,sunau
,telnetlib
,uu
,xdrlib
.Remove (1):
lib2to3
.
Python 3.12: 301 modules
Add (4):
_sha2
,_pylong
,_pydatetime
,_wmi
.
Remove (8):
_bootsubprocess
,_sha256
,_sha512
,asynchat
,asyncore
,distutils
,imp
,smtpd
Python 3.11: 305 modules
Add (3):
tomllib
(PEP 680),_tokenize
,_typing
.
Remove (1):
binhex
.
Python 3.10: 303 modules
sys.stdlib_module_names was added to Python 3.10. For Python 2.6 to 3.9, the 3rd party stdlib-list module can be used.
Talks¶
2023: Language Summit 2023: What is the stdlib for? by Brett Cannon
2021: The 2021 Python Language Summit: What Is the stdlib? by Brett Cannon
2019: Batteries Included, But They’re Leaking by Amber Brown
Maintain the stdlib outside Python?¶
2021: cpython_hack: David Beazley’s experiment to make the Python stdlib as small as possible. The stdlib is made of 7 Python modules and 3 C extensions.
stdlib Python modules:
genericpath
io
os
posixpath
site
stat
types
stdlib C extensions:
_stat
posix
readline
There is an extra
Lib/__phello__.foo.py
module, but it’s only used for tests.2019: If Python started moving more code out of the stdlib and into PyPI packages, what technical mechanisms could packaging use to ease that transition? by Nathaniel J. Smith
Stdlib history¶
Python 3.13¶
Python 3.13 removed 20 module:
lib2to3
: deprecated in Python 3.11, issue #104780, PEP 617aifc
: PEP 594audioop
: PEP 594cgi
: PEP 594cgitb
: PEP 594chunk
: PEP 594crypt
: PEP 594imghdr
: PEP 594mailcap
: PEP 594msilib
: PEP 594nis
: PEP 594nntplib
: PEP 594ossaudiodev
: PEP 594pipes
: PEP 594sndhdr
: PEP 594spwd
: PEP 594sunau
: PEP 594telnetlib
: PEP 594uu
: PEP 594xdrlib
: PEP 594
Python 3.12¶
Python 3.12 removed 5 module:
asynchat
: deprecated in Python 3.6, PEP 594asyncore
: deprecated in Python 3.6, PEP 594distutils
: deprecated in Python 3.10, PEP 632 - Deprecate distutils moduleimp
: deprecated in Python 3.5, issue #98040, PR #98573, replaced withimportlib
smtpd
: deprecated in Python 3.6, PEP 594
PEP 594¶
PEP 594 – Removing dead batteries from the standard library scheduled the removal of many stdlib modules in Python 3.12 and 3.13.
Python 3.11¶
Python 3.11 added 1 module:
Python 3.11 added 1 sub-module to existing packages:
wsgiref.types
Python 3.11 removed 1 module:
binhex
: deprecated in Python 3.9, issue #89248.
Note: asyncore
, asynchat
, smtplib
were removed in Python 3.11,
but then the SC asked to add them back
Python 3.10¶
Python 3.10 removed 3 modules:
formatter
: deprecated in Python 3.4, issue #86465, python-dev threadparser
: deprecated in Python 3.9, PEP 617 (PEG parser)symbol
: deprecated in Python 3.9, PEP 617
Python 3.9¶
Python 3.9 added 2 modules:
graphlib
zoneinfo
Python 3.9 removed 2 modules:
dummy_threading
: deprecated in Python 3.7; Python 3.7 requires threads to build: bpo-31370._dummy_thread
: same.
Python 3.8¶
Python 3.8 added 1 sub-module to existing packages:
importlib.metadata
Python 3.8 removed 1 module:
macpath
: deprecated in Python 3.7, issue #79652, Mac OS 9 is no longer used.
Python 3.7¶
Python 3.7 added 2 modules:
contextvars
: PEP 567 – Context Variablesdataclasses
: PEP 557 – Data Classes
Python 3.7 added 1 sub-module to existing packages:
importlib.resources
: issue #76429
Python 3.7 removed 2 modules:
fpectl
: issue #73323, it was never enabled by default, never worked correctly on x86-64, and it changed the Python ABI in ways that caused unexpected breakage of C extensions.macurl2path
: issue #72512
Python 3.6¶
Python 3.6 added 1 module:
Python 3.6 removed 6 modules:
CDIO
: issue #72214CDROM
: issue #72214DLFCN
: issue #72214IN
: issue #72214STROPTS
: issue #72214TYPES
: issue #72214
issue #72214: These removed modules were undocumented. They had been
available in the platform specific Lib/plat-*/
directories, but were
chronically out of date, inconsistently available across platforms, and
unmaintained.
Python 3.5¶
Python 3.5 added 2 modules:
Python 3.4¶
Python 3.4 added 7 modules:
asyncio
: PEP 3156 – Asynchronous IO Support Rebooted: the “asyncio” Moduleensurepip
enum
: PEP 435 – Adding an Enum type to the Python standard librarypathlib
: PEP 428 – The pathlib module – object-oriented filesystem pathsselectors
: PEP 3156statistics
: PEP 450 – Adding A Statistics Module To The Standard Librarytracemalloc
: PEP 454 – Add a new tracemalloc module to trace Python memory allocations
Python 3.3¶
Python 3.3 added 4 modules:
faulthandler
: issue #55602ipaddress
: PEP 3144 – IP Address Manipulation Library for the Python Standard Librarylzma
: issue #50964
Python 3.3 added 1 sub-module to existing packages:
unittest.mock
Python 3.2¶
Python 3.2 added 2 modules:
argparse
: PEP 389 – argparse - New Command Line Parsing Moduleconcurrent.futures
: PEP 3148 – futures - execute computations asynchronously
Python 3.1¶
Python 3.1 added 1 module:
importlib
Python 3.1 added 1 sub-module to existing packages:
tkinter.ttk
Python 3.0¶
Python 3.0 removed 74 stdlib modules, related to PEP 3108.
Moreover, many Python 2.7 modules have been renamed by PEP 3108.
Removed Mac modules (24):
aepack
aetools
aetypes
buildtools
Carbon
cfmfile
ColorPicker
EasyDialogs
findertools
fm
FrameWork
gensuitemodule
ic
icopen
mac
macerrors
MacOS
macosa
macostools
macresource
MiniAEFrame
Nav
PixMapWrapper
videoreader
Removed IRIX modules (7):
al
DEVICE
flp
gl
: Functions from the Silicon Graphics Graphics Library.imgfile
: Support for SGI imglib filesjpeg
: Read and write JPEG filessgi
: random SGI-specific things
Removed modules, replaced by the email
package (5):
mimetools
MimeWriter
mimify
multifile
rfc822
Other removed modules (38):
audiodev
: Classes for manipulating audio devices (currently only for Sun and SGI)Bastion
: Providing restricted access to objectsbsddb
Canvas
(tk)cd
: CD Audio Librarycommands
: Utility functions for running external commandscompiler
: analyze Python source code and generating Python bytecodedircache
: read directory listing with cachedl
:dl.open()
exceptions
: Standard exception classesFixTk
: Delay import _tkinter until we have set TCL_LIBRARY, imported by Tkinter`fl
: interface to Mark Overmars’ FORMS Libraryfpformat
: General floating point formatting functionsfuture_builtins
: Python 3 builtinsihooks
: Import hook supportimageop
: Manipulate raw image data, replaced with PIL/Pillowimputil
: Import utilitieslinuxaudiodev
: Linux audio device (/dev/dsp
) for python, replaced byossaudiodev
.markupbase
: Renamed to_markupbase
, used byhtml.parser
md5
: Replaced byhashlib
mhlib
: Manipulate MH mailboxes from Pythonmutex
: Lock and queue for mutual exclusionnew
: Interface to the creation of runtime implementation objectsos2emxpath
: Common operations on OS/2 pathnamespopen2
: Subprocesses with accessible I/O streamsposixfile
: File-like objects with locking supportrexec
: Restricted execution frameworksets
: Unordered collections of unique elements, replaced byset()
built-in typesgmllib
: Simple SGML parsersha
: Replaced byhashlib
sre
: Replaced byre
statvfs
: Replaced byos.statvfs()
stringold
: Collection of string operationsstrop
: Common string manipulations, optimized for speed (C extension)sunaudiodev
(SunOS): Access to Sun audio hardwaretoaiff
: Convert “arbitrary” sound files to AIFF (Apple and SGI’s audio format)user
: Hook to allow user-specified customization code to runxmllib
: Parser for XML, using the derived class as static DTD.