Skip to main content

tradeoff

Choose between options when none is best on every count.

pip install tradeoff
import tradeoff

flights = [
    {"name": "A", "price": 420, "hours": 7.5, "stops": 0},
    {"name": "B", "price": 260, "hours": 11.0, "stops": 1},
    {"name": "C", "price": 300, "hours": 12.5, "stops": 2},
    {"name": "D", "price": 180, "hours": 19.0, "stops": 2},
]

# The options worth considering: C is out, because B is cheaper, faster and has fewer stops.
tradeoff.pareto(flights, minimize=["price", "hours", "stops"])  # A, B, D

# All options, best first. Price matters twice as much as time.
tradeoff.rank(flights, {"price": -2, "hours": -1})  # B, D, C, A
  • pareto(options, maximize=[...], minimize=[...]): the options no other option beats on every count, in their original order.
  • rank(options, weights): all options, best first. Each criterion is scaled to 0..1 across the options, then weighted. A positive weight means more is better, a negative one means less is better.
  • scores(options, weights): each option with its score.
  • dominates(a, b, maximize=[...], minimize=[...]): whether a beats b on every count.

A criterion is a dict key, an attribute name, or a function that takes an option and returns a number. No dependencies. Python 3.9 or newer.

License

Apache-2.0

Metadata

Release files for tradeoff 0.1.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 tradeoff 0.1.0
File Size Uploaded Provenance Actions
tradeoff-0.1.0.tar.gz 7.4 kB Without provenance Details for tradeoff-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 15.0 kB

Release files / tradeoff-0.1.0.tar.gz

Download URL tradeoff-0.1.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
eb153d2ee6e964e012f8bdfb0ae5be4bce9763767ac0275e57eba011e3dfb6c8
BLAKE2b-256 checksum
How to use checksums
8a2d5d666fbcb2fb88238f8b350f772cb5a73ef20d4feee403bf56b43ff84aca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Release files / tradeoff-0.1.0-py3-none-any.whl

Download URL tradeoff-0.1.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c12b205f4ed9ba558a16161d9c419eddd0458b38dd4b076d0123bcc5ebd00ca
BLAKE2b-256 checksum
How to use checksums
3c757e10114dfadffc89796857842b81cbdd8cfed9cd3ec1bc90e35bd21b4d6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.11

Security for tradeoff 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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