Skip to content

Partition Sets

Consolidation of existing third party recipes for partitioning of sets and multisets/bags.

Partition Sets provides a consolidated set of recipes gently provided by other users over the years and under the MIT license. I modified these slightly so that they now equally work under python2 and python3. All bugs are mine ;-)

You may find it useful for tasks involving small sets and also multi sets/bags.

License: MIT | Country of origin: Switzerland | Export control classification number(ECCN): EAR99

Third party dependencies are documented in the folder third-party.

version downloads wheel supported-versions supported-implementations maintenance-status

Bug Tracker

Any feature requests or bug reports shall go to the todos of partitionsets.

Primary Source repository

The main source of partitionsets is on a mountain in central Switzerland. We use distributed version control (git). There is no central hub. Every clone can become a new source for the benefit of all. The preferred public clones of partitionsets are:

  • on codeberg - a democratic community-driven, non-profit software development platform operated by Codeberg e.V.
  • at sourcehut - a collection of tools useful for software development.


Please do not submit "pull requests" (I found no way to disable that "feature" on GitHub). If you like to share small changes under the repositories license please kindly do so by sending a patchset. You can either send such a patchset per email using git send-email or if you are a sourcehut user by selecting "Prepare a patchset" on the summary page of your fork at sourcehut.


Please kindly submit issues at or write plain text email to ~sthagen/ to submit patches and request support. Thanks.

Thanks also to

This package merely wraps up several recipes (and comments) gently provided under the MIT license through several people. Those I noticed have been noted below. Any missing names are my fault. In case I get notified, I will try to update, add or remove items in below lists accordingly.


  • Anton Vredegoor
  • Chris Haulk


  • Don Sawatzky
  • Emil Wall
  • Raymond Hettinger


  • Nathan Hurst send feedback and a patch for version 0.1.1 - thanks

For further reference please see the comments of the module files.


[A0001101]: "Bell or exponential numbers: ways of placing n labeled balls into n indistinguishable boxes." at

[BellNumber]: Wikipedia entry Bell_number at

[OEIS]: Wikipedia entry On-Line_Encyclopedia_of_Integer_Sequences at

[OrdSetImplPy]: (mixed with the simplified code from Don Sawatzky's comment, which is sufficient for this task)

[PartOfASet_WP]: Wikipedia entry Partition_of_a_set at