Skip to main content

A set that works with both hashable and non-hashable elements

Project description

All Purpose Set

Table of Contents

What is it?

  • A set which doesn't require hashable contents

Why create it?

  • I often have a need to store non-hashable contents in a set. For example storing a dict isn't possible with the builtin set.

    # doesn't work
    someDict = { "key": "value" }
    someSet = { someDict }

Simple usage

from all_purpose_set import ApSet

someDict = { "key": "value" }
someSet = ApSet([someDict])

print(someDict in someSet) # prints True

See also


Note: This api is young and subject to change quite a bit. There also may be functionality present in the builtin set which this set doesn't cover. I'm willing to add it so please just raise a github issue or PR with details.

class ApSet([a list])

  • all methods return self unless specified otherwise
  • iterates in the order of insertion
  • currently the internal methods implemented are
    • __contains__
    • __iter__
    • __len__
has(something) => bool
  • a function alternative to key in aSet
  • raises a KeyError if the element doesn't exist


# you must have poetry installed
$ poetry shell
$ poetry install
$ python

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for all-purpose-set, version 0.1.10
Filename, size File type Python version Upload date Hashes
Filename, size all_purpose_set-0.1.10-py3-none-any.whl (208.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size all_purpose_set-0.1.10.tar.gz (178.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page