Skip to main content

impartial

build PyPI PyPI - Python Version Licence

impartial is a lightweight extension of functools.partial that allows modifying positional and keyword arguments in a functional style.

The main idea is that any function wrapped with impartial gets a method with_<keyword>(value) for every keyword argument of that function. Each with_<keyword>(value) method returns a new impartial function with that keyword being modified.

>>> from impartial import impartial
>>> @impartial
... def power(x, exponent):
...     return x ** exponent
...
>>> power
impartial(<function power at 0x10d54e790>)
>>> square = power.with_exponent(2) # behaves like functools.partial(square, exponent=2)
>>> square
impartial(<function power at 0x10d54e790>, exponent=2)
>>> square(3)
9

Features:

  • the with_<keyword>(value) methods can be arbitrarily chained
  • impartial functions are immutable: any "modification" of arguments returns a new impartial function
  • very lightweight (~50 LOC and no dependencies)
  • fully compatible with functools.partial (impartial is a subclass of functools.partial)
  • can be used as a decorator

To install this package, run:

pip install impartial

Metadata

Release files for impartial 0.2.0

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

Source distribution (sdist)

Source distribution for impartial 0.2.0
File Size Uploaded Provenance Actions
impartial-0.2.0.tar.gz 7.4 kB Without provenance Details for impartial-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 19.1 kB

Release files / impartial-0.2.0.tar.gz

Download URL impartial-0.2.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
632bc680f4b9742ea37325392299a4f3022db6572e576166adae530d62512f62
BLAKE2b-256 checksum
How to use checksums
79c615c938240cbf83cef52748477fc8f21c9a95eea1bcbcf439fc5415e1b53f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

Release files / impartial-0.2.0-py3-none-any.whl

Download URL impartial-0.2.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95ec9e35c39384d13e09dd174299a4d4412124469ac9fdca94babab926d810d3
BLAKE2b-256 checksum
How to use checksums
0de254170daeb833c63b0fccc8288adc9420e2d9b304ae73d537bca1e5b5b040
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

Security for impartial 0.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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