Skip to main content

pythonwrench

Python Build Documentation Status

Python library with tools for typing, manipulating collections, and more!

Installation

With uv:

uv add pythonwrench

With pip:

pip install pythonwrench

This library has been tested on all Python versions 3.8 - 3.14, requires only typing_extensions>=4.10.0, and runs on Linux, Mac and Windows systems.

Examples

Typing

Check generic types with isinstance_generic :

>>> import pythonwrench as pw
>>>
>>> # Behaves like builtin isinstance() :
>>> pw.isinstance_generic({"a": 1, "b": 2}, dict)
... True
>>> # But works with generic types !
>>> pw.isinstance_generic({"a": 1, "b": 2}, dict[str, int])
... True
>>> pw.isinstance_generic({"a": 1, "b": 2}, dict[str, str])
... False

... or check specific methods with protocols classes beginning with Supports

>>> import pythonwrench as pw
>>>
>>> isinstance({"a": 1, "b": 2}, pw.SupportsIterLen)
... True
>>> isinstance({"a": 1, "b": 2}, pw.SupportsGetitemLen)
... True

Finally, you can also force argument type checking with check_args_types function :

>>> import pythonwrench as pw

>>> @pw.check_args_types
>>> def f(a: int, b: str) -> str:
>>>     return a * b

>>> f(1, "a")  # pass check
>>> f(1, 2)  # raises TypeError from decorator

Collections

Provides functions to facilitate iterables processing, like unzip :

>>> import pythonwrench as pw
>>>
>>> list_of_tuples = [(1, "a"), (2, "b"), (3, "c"), (4, "d")]
>>> pw.unzip(list_of_tuples)
... [1, 2, 3, 4], ["a", "b", "c", "d"]
>>> pw.flatten(list_of_tuples)
... [1, "a", 2, "b", 3, "c", 4, "d"]

... or mathematical functions like prod or argmax :

>>> import pythonwrench as pw
>>>
>>> values = [3, 1, 6, 4]
>>> pw.prod(values)
... 72
>>> pw.argmax(values)
... 2
>>> pw.is_sorted(values)
... False

Easely converts common python structures like list of dicts to dict of lists :

>>> import pythonwrench as pw
>>>
>>> list_of_dicts = [{"a": 1, "b": 2}, {"a": 3, "b": 4}]
>>> pw.list_dict_to_dict_list(list_of_dicts)
... {"a": [1, 3], "b": [2, 4]}

... or dict of dicts :

>>> import pythonwrench as pw
>>>
>>> dict_of_dicts = {"a": {"x": 1, "y": 2}, "b": {"x": 3, "y": 4}}
>>> pw.flat_dict_of_dict(dict_of_dicts)
... {"a.x": 1, "a.y": 2, "b.x": 3, "b.y": 4}

Disk caching (memoize)

>>> import pythonwrench as pw
>>>
>>> @pw.disk_cache_decorator
>>> def heavy_processing():
>>>     # Lot of stuff here
>>>     ...
>>>
>>> data1 = heavy_processing()  # first call function is called and the result is stored on disk
>>> data2 = heavy_processing()  # second call result is loaded from disk directly

Semantic versionning parsing

>>> import pythonwrench as pw
>>> version = pw.Version("1.12.2")
>>> version.to_tuple()
... (1, 12, 2)
>>> version = pw.Version("0.5.1-beta+linux")
>>> version.to_tuple()
... (0, 5, 1, "beta", "linux")

>>> Version("1.3.1") < Version("1.4.0")
... True

Serialization

>>> import pythonwrench as pw
>>>
>>> list_of_dicts = [{"a": 1, "b": 2}, {"a": 3, "b": 4}]
>>> pw.dump_csv(list_of_dicts, "data.csv")
>>> pw.dump_json(list_of_dicts, "data.json")
>>> pw.load_json("data.json") == list_of_dicts
... True

Lazy loading

To speed up this package loading, you can install it with uv add pythonwrench[lazy], so import pythonwrench as pw will be faster.

Contact

Maintainer:

Metadata

Release files for pythonwrench 0.6.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pythonwrench 0.6.7
File Size Uploaded
pythonwrench-0.6.7.tar.gz 279.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pythonwrench 0.6.7
File Interpreter ABI Platform
pythonwrench-0.6.7-py3-none-any.whl Python 3 none any Details

Total release size: 357.7 kB

Release files / pythonwrench-0.6.7.tar.gz

Download URL pythonwrench-0.6.7.tar.gz
Size 279.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6772c108b0b5d33e7a6ae51c71dfc4ccf50c66c508bf52074567eb0db5ca89fb
BLAKE2b-256 checksum
How to use checksums
4123259da64a24388b6ae6f54acfa99122d6d43bcbb3745ad8a3021394e94114
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pythonwrench-0.6.7-py3-none-any.whl

Download URL pythonwrench-0.6.7-py3-none-any.whl
Size 78.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
790584532147378962936bab84ab3e06ae348e1c7a05f9c918bb7d6768da0f27
BLAKE2b-256 checksum
How to use checksums
cc6c163a8c6adf7c9b938dfd52454771778d8724ab620a872ca32fa604e498c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.7 This release

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.10

1 release file

0.4.9

1 release file

0.4.8

1 release file

0.4.7

1 release file

0.4.6

1 release file

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page