sparsedlist
sparsedlist is endless list with non-contiguous indexes. Based on Skip list data structure. Python3 is used.
sparsedlist is a list structure, where set of indexes can have “gaps” and you can put a value to any index. In other words, the structure is similar to dict, but has list interface and sorted numeric indexes.
Since skiplist structure is used as machinery, then you have fast forward iteration with O(1) complexity and pretty good indexation/insertion/deletion with O(log n) complexity.
Example:
>>> from sparsedlist import SparsedList
>>> s = SparsedList()
>>> s[180] = 'rock the microphone'
>>> s[10:20] = range(10)
>>> print(s)
SparsedList{{10: 0, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 9, 180: 'rock the microphone'}}
>>> print(s[180])
rock the microphone
>>> print(s[-1])
rock the microphone
>>> print(s[-2])
None
>>> print(list(s[18:23]))
[8, 9, None, None, None]
>>> print(s[100500])
None
By default sparsedlist substitutes item on None value if it has not set. To disable this feature, pass required param to constructor. Then IndexError will be raised on getting unset items. For instance:
>>> from sparsedlist import SparsedList
>>> s = SparsedList(required=True)
>>> s[10:20] = range(10)
>>> print(s[100500])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/sparsedlist.py", line 73, in __getitem__
raise IndexError("Item with index '{}' does not exist".format(item))
IndexError: Item with index '100500' does not exist
>>> print(list(s[18:25]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/sparsedlist.py", line 73, in __getitem__
raise IndexError("Item with index '{}' does not exist".format(item))
IndexError: Item with index '20' does not exist
Dependencies
pyskiplist only. Tested on python3.6.
Installation
pip3 install sparsedlist
Metadata
Release files for sparsedlist 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sparsedlist-0.4.tar.gz | 5.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sparsedlist-0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / sparsedlist-0.4.tar.gz
| Download URL | sparsedlist-0.4.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bbd2284c0b29b12a94e611cc8a7ebcf38449bd6b81f1e3bc1c402926820cbd0d
|
|
BLAKE2b-256 checksum How to use checksums |
a89a0087b24a0cb3278edd8e60b82878788c2fd7234c0f36259a95823b81486a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6rc1+
|
Release files / sparsedlist-0.4-py3-none-any.whl
| Download URL | sparsedlist-0.4-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4978184ce4c188f4300febfa8a1db5fb427928fa6069f155c55c09bb5d9b6872
|
|
BLAKE2b-256 checksum How to use checksums |
af30aedd6a638c636bc77b50679fe7c8be01200b521f516da2c2aa16e903bed3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6rc1+
|
Security for sparsedlist 0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.