binpacking
Heuristic distribution of weighted items to bins (either a fixed number of bins or a fixed number of volume per bin). Data may be in form of list, dictionary, list of tuples or csv-file.
What it is and what it does
binpacking solves two classic bin packing problems using greedy heuristics. The first distributes items into exactly N bins with approximately balanced total weight per bin (useful for load balancing across a fixed number of workers). The second distributes items into the minimum number of bins, each respecting a maximum capacity constraint (useful for minimizing resource allocations). The package accepts input as lists, dictionaries, lists of tuples, or CSV files, and includes both pure Python and optional NumPy-accelerated implementations.
The algorithms are Least Loaded Fit Decreasing for constant-volume packing and Longest Processing Time for constant-bin-number packing. Both sort items by weight descending before placement. This is a straightforward, dependency-free tool for scheduling, resource allocation, and partitioning problems where exact optimality is less critical than a fast, reasonable solution.
Use it for:
- Distribute jobs with known durations across a fixed number of CPU cores to minimize total runtime.
- Group files of different sizes into memory allocations to minimize the number of program runs needed.
- Pack items into containers or shipments with a maximum weight limit to minimize the number of containers.
- Partition data into batches for parallel processing while keeping batch sizes roughly equal.
- Schedule tasks across servers with fixed capacity to balance load.
- Bin CSV rows by a weight column for resource planning or logistics optimization.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Distributes weighted items into bins using greedy algorithms, either to a fixed number of bins with balanced loads or to the minimum bins with a maximum capacity constraint.
Yes. The package solves a real, common problem with zero dependencies, low install friction, and a permissive license. The greedy algorithms are fast and adequate for most practical load-balancing and partitioning tasks. Maintenance is aging but the code is stable and the repository is not abandoned. Install it if you need to distribute weighted items across fixed bins or minimize bin count.
Install
binpacking on PyPI
pip
pip install binpackinguv
uv add binpackingpoetry
poetry add binpackingInstalling binpacking
Before you install
Low friction: pure Python wheel with no required dependencies. Maintenance status is aging—last release 204 days ago, but the repository is active and not archived.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install binpacking
import binpacking
b = {'a': 10, 'b': 10, 'c': 11, 'd': 1, 'e': 2, 'f': 7}
bins = binpacking.to_constant_bin_number(b, 4)
print(bins)
Requires Python 3.10+
Verify before relying
- How well the greedy algorithms perform compared to optimal solutions on typical problem sizes.
- Whether NumPy acceleration provides meaningful speedup for the datasets you plan to pack.
- Real-world accuracy of the Least Loaded Fit Decreasing and Longest Processing Time heuristics for your domain.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 204 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 265,679/month — #8,319 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: binpacking-2.0.1-py3-none-any.whl
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
prtpyImplements multiway number partitioning and bin…
permissive · top 15,000 on PyPI
py3dbpSolves the 3D bin packing problem by fitting…
permissive · top 5,000 on PyPI
roundrobinProvides four round-robin selection algorithms:…
permissive · top 15,000 on PyPI
rectpackRectpack solves the 2D bin packing problem by…
permissive · top 15,000 on PyPI
rectangle-packerPacks a set of rectangles with fixed…
permissive · top 15,000 on PyPI
comfy-aimdoA PyTorch VRAM allocator that dynamically…
unclear · top 5,000 on PyPI
optbinningOptBinning discretizes numeric variables into…
permissive · top 15,000 on PyPI
scs4onnxCompresses ONNX model files by deduplicating…
permissive · top 15,000 on PyPI
circular-dictCircularDict is a Python dictionary that…
permissive · top 5,000 on PyPI
omnimallocOmniMalloc solves static memory allocation for…
permissive · top 15,000 on PyPI