skillfed

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.

binpacking v2.0.1 265.7K downloads/30d#8,319 on PyPI97
Permissive license MIT AGING released

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 binpacking

uv

uv add binpacking

poetry

poetry add binpacking

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13

Tags

bin packing algorithmload balancing distributionpartition items into binsconstant volume packingjob scheduling to coresweight distributiongreedy bin allocation
schedulingresource-allocationheuristic

More Mathematics packages