sliceit
Dynamically sized slice views which avoid storing their own data.
The builtin list, tuple, str, etc., create copies when sliced. This is to allow all of the unnecessary memory to be freed if it is no longer needed. In some cases, the opposite problem occurs, where none of the memory needs to be freed anyways, meaning slices simply take up more space than necessary.
Some data structures provide slicing views already, such as:
- numpy
- pandas
- tensorflow
- and many other data science packages
If these packages already fit your needs, consider using them instead.
What's different?
sliceit provides sliceable views any Sequence (or MutableSequence),
meaning it works for lists, tuples, strings, etc., and can also be used
as an easy way to implement slicing for custom classes.
Furthermore, sliceit uses lazily evaluated slices. This means the
underlying data is free to change size as much as it wants. The catch
is that some objects may raise runtime errors if you try iterating
over them at the same time.
Unlike some, sliceit is also recursively sliceable and supports mutations,
although modifying slices may in some cases be unintuitive.
Install
Unix/macOS:
python3 -m pip install sliceit
Windows:
py -m pip install sliceit
Examples
from sliceit import sliceit
print("Create a slice view of some data.")
L = list(range(10))
S = sliceit(L)[::-1]
print(f"L = {L}")
print(f"list(S) = {list(S)}")
print()
print("Slices act as a view over the data.")
print(f"list(S) = {list(S)}")
L[0] = -10
print(f"L[0] := -10")
print(f"list(S) = {list(S)}")
L[0] = 0
print(f"L[0] := 0")
print(f"list(S) = {list(S)}")
print()
print("They can be looped over or indexed as you would expect.")
print(f"[x for x in S] = {[x for x in S]}")
print(f"S[0] = {S[0]}")
print()
print("If the data is mutable, the slice is mutable.")
S[0] = 0
print("S[0] := 0")
print(f"L[-1] = {L[-1]}")
S[0] = 9
print("S[0] := 9")
print(f"L[-1] = {L[-1]}")
Metadata
Release files for sliceit 0.0.1
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 | |
|---|---|---|---|---|
| sliceit-0.0.1.tar.gz | 5.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sliceit-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / sliceit-0.0.1.tar.gz
| Download URL | sliceit-0.0.1.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fc557f17f306e0ce40be269c5ad2a9e4686006508bb8115f7cd99b12856eabd
|
|
BLAKE2b-256 checksum How to use checksums |
3b46b2f4c7145c5de91731389a1d6242647a3868e7c63cfb5adeb34f6e3b04b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
|
Release files / sliceit-0.0.1-py3-none-any.whl
| Download URL | sliceit-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1e768496d4b2bdc2a804c876a422997c2b7c14ec928c1f7ad2986de8ab6be89
|
|
BLAKE2b-256 checksum How to use checksums |
e86f642d090d55171bc76acbf248ef4cb630b71b395e202c3452223edbb2e4ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
|
Security for sliceit 0.0.1
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.