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.
Release files for hybridset 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hybridset-1.0.tar.gz | 16.5 kB | Details |
Release files / hybridset-1.0.tar.gz
| Download URL | hybridset-1.0.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b0ba972dccf02e585d8f75e0b80e17165978b27258a3c5d6b8ef245baa3b457
|
|
BLAKE2b-256 checksum How to use checksums |
5bed2adf325300b136d542468420f1ce21bd85cf49bf1436326722593320e091
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|