prtpy
Number partitioning in Python
What it is and what it does
prtpy provides a collection of algorithms for partitioning numbers into bins and packing items into fixed-capacity bins. It supports both exact methods (via integer linear programming through the mip library) and approximate greedy algorithms, allowing you to choose between solution quality and computation speed. The package wraps numpy and scipy for numerical operations and can optionally use GUROBI for faster ILP solving.
You supply items (with numeric values), a target number of bins or bin capacity, and an optimization objective (e.g., maximize the smallest bin sum, minimize the largest bin sum). The library returns the assignment of items to bins. It's designed for load-balancing, resource allocation, and scheduling problems where you need to distribute work or items fairly or efficiently across a fixed number of containers.
Use it for:
- Distribute computational tasks across multiple processors to minimize makespan (longest task completion time).
- Pack items into shipping containers to minimize the number of containers or maximize container utilization.
- Allocate workload across servers to balance CPU or memory usage and avoid overload.
- Partition a dataset into balanced subsets for parallel processing or cross-validation in machine learning.
- Solve fair division problems where items must be split among parties with minimal imbalance.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements multiway number partitioning and bin packing algorithms with support for exact and approximate methods, multiple input formats, and configurable optimization objectives.
Yes, if you need a flexible, permissively licensed partitioning or bin-packing solver. The low install friction and zero known vulnerabilities are strengths. However, the aging maintenance status (last release over a year ago, Pre-Alpha classifier) and lack of recent activity suggest treating it as stable but not actively developed—suitable for production use if the algorithm suite meets your needs, but do not expect rapid bug fixes or new features.
Install
prtpy on PyPI
pip
pip install prtpyuv
uv add prtpypoetry
poetry add prtpyInstalling prtpy
Before you install
Low friction installation with three core runtime dependencies (numpy, scipy, mip). Package is aging—last release was 2024-05-15, over a year ago—but the repository remains active with recent commits and no archived status.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal obligations beyond attribution.
Quickstart
pip install prtpy
import prtpy
prtpy.partition(algorithm=prtpy.partitioning.greedy, numbins=2, items=[1,2,3,4,5])
Requires Python 3.8 or later. Optional: GUROBI solver can accelerate ILP-based algorithms via python-mip.
Verify before relying
- Whether the package's Pre-Alpha status reflects incomplete feature coverage or simply conservative versioning.
- Current performance characteristics and scalability limits for large item sets or bin counts.
- Whether the 821 days since last release indicates maintenance abandonment or stable maturity.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — numpy, scipy, mip |
| Maintenance | aging — 821 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 391,716/month — #7,013 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: prtpy-0.8.3-py3-none-any.whl
Keywords: optimization, partition
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
binpackingDistributes weighted items into bins using…
permissive · top 15,000 on PyPI
py3dbpSolves the 3D bin packing problem by fitting…
permissive · top 5,000 on PyPI
rectpackRectpack solves the 2D bin packing problem by…
permissive · top 15,000 on PyPI
optbinningOptBinning discretizes numeric variables into…
permissive · top 15,000 on PyPI
mipPython MIP models and solves mixed-integer…
copyleft · top 15,000 on PyPI
rectangle-packerPacks a set of rectangles with fixed…
permissive · top 15,000 on PyPI
lapSolves the linear assignment problem using the…
permissive · top 5,000 on PyPI
gurobipygurobipy is a Python interface to the Gurobi…
unclear · top 5,000 on PyPI
pymoopymoo implements single- and multi-objective…
permissive · top 5,000 on PyPI