boltons
boltons should be builtins.
Boltons is a set of pure-Python utilities in the same spirit as — and yet conspicuously missing from — the standard library, including:
Atomic file saving
, bolted on withfileutils
A highly-optimized
OrderedMultiDict
, indictutils
Two types of
PriorityQueue
, inqueueutils
A full-featured
TracebackInfo
type, for representing stack traces, intbutils
A lightweight
UTC timezone
available intimeutils
.Recursive mapping for nested data transforms, with
remap
And that’s just a small selection. As of November 28, 2024, boltons
is
87 types and 169 functions, spread across
29 modules. See them all in the Index, and see
what’s new by checking the CHANGELOG.
Installation and Integration
Boltons can be added to a project in a few ways. There’s the obvious one:
pip install boltons
On macOS, it can also be installed via MacPorts:
sudo port install py-boltons
Then dozens of boltons are just an import away:
from boltons.cacheutils import LRU
lru_cache = LRU()
lru_cache['result'] = 'success'
Due to the nature of utilities, application developers might want to consider other integration options. See the Integration section of the architecture document for more details.
Boltons is tested against Python 3.7-3.12, as well as PyPy3.
Third-party packages
The majority of boltons strive to be “good enough” for a wide range of
basic uses, leaving advanced use cases to Python’s myriad specialized
3rd-party libraries. In many cases the respective boltons
module
will describe 3rd-party alternatives worth investigating when use
cases outgrow boltons
. If you’ve found a natural “next-step”
library worth mentioning, consider filing an issue!
Gaps
Found something missing in the standard library that should be in
boltons
? Found something missing in boltons
? First, take a
moment to read the very brief Architecture statement to make
sure the functionality would be a good fit.
Then, if you are very motivated, submit a Pull Request. Otherwise, submit a short feature request on the Issues page, and we will figure something out.
Section listing
- Architecture
cacheutils
- Caches and cachingdebugutils
- Debugging utilitiesdictutils
- Mapping types (OMD)ecoutils
- Ecosystem analyticsfileutils
- Filesystem helpersformatutils
-str.format()
toolboxfuncutils
-functools
fixesgcutils
- Garbage collecting toolsioutils
- Input/output enhancementsiterutils
-itertools
improvementsjsonutils
- JSON interactionslistutils
-list
derivativesmathutils
- Mathematical functionsmboxutils
- Unix mailbox utilitiesnamedutils
- Lightweight containerspathutils
- Filesystem funqueueutils
- Priority queuessetutils
-IndexedSet
typesocketutils
-socket
wrappersstatsutils
- Statistics fundamentalsstrutils
- Text manipulationMultiReplace
a10n()
args2cmd()
args2sh()
asciify()
bytes2human()
camel2under()
cardinalize()
complement_int_list()
escape_shell_args()
find_hashtags()
format_int_list()
gunzip_bytes()
gzip_bytes()
html2text()
indent()
int_ranges_from_int_list()
is_ascii()
is_uuid()
iter_splitlines()
multi_replace()
ordinalize()
parse_int_list()
pluralize()
singularize()
slugify()
split_punct_ws()
strip_ansi()
under2camel()
unit_len()
unwrap_text()
tableutils
- 2D data structuretbutils
- Tracebacks and call stackstimeutils
-datetime
additionstypeutils
- Type handlingurlutils
- Structured URL
(For a quick reference you can ctrl-F, see the Index.)