Skip to main content

Mutable set storing apart hashables and unhashables values

Project description

Hybrid Set

HybridSet is a MutableSet that stores apart hashable and unashable values.
It's fully compatible with the builtins set and frozenset

>>> from hybridset import HybridSet
>>> hs = HybridSet([3, 'thing', [True], {3, 4}, {1: 'one', 2: 'two'}])
>>> s = {3, 4, 5}
>>> s | hs
HybridSet(hashables={3, 4, 5, 'thing'}, unhashables=[[Ture], {3, 4}, {1: 'one', 2: 'two'}])
>>> s & hs
HybridSet(hashables={3})

Know Issues

Don't pass HybridSet instances to explicit methods of builtins, it may cause a TypeError because of the unhashable values present in the HybridSet.

>>> hs = HybridSet([[6], [7]])
>>> s.union(hs)
Traceback (most recent call last):
 ...
TypeError: unhashable type: 'list'
>>> s.isdisjoint(hs)
Traceback (most recent call last):
 ...
TypeError: unhashable type: 'list'

Always use operators instead.
For isdisjoint(), test the emptiness of the intersection:

>>> if not s & hs:
...     print('disjoint')
... else:
...     print('not disjoint')
disjoint

For more information, see the class and methods docstrings.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distribution

hybridset-1.0.tar.gz (16.5 kB view details)

Uploaded Source

File details

Details for the file hybridset-1.0.tar.gz.

File metadata

  • Download URL: hybridset-1.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for hybridset-1.0.tar.gz
Algorithm Hash digest
SHA256 2b0ba972dccf02e585d8f75e0b80e17165978b27258a3c5d6b8ef245baa3b457
MD5 b8872f2bde7fd28682d9192d216f62c1
BLAKE2b-256 5bed2adf325300b136d542468420f1ce21bd85cf49bf1436326722593320e091

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page