Pre-release
This release is a pre-release and may not be stable for production use.
lazily-sliced
A memory-efficient Python sequence wrapper that applies slicing operations lazily, deferring data access until elements are actually needed.
Features
- Zero-copy slicing: Avoids immediate data duplication when slicing sequences
- Full Sequence interface: Implements all
collections.abc.Sequenceoperations - Portable: Python 2 & 3 compatible, no dependencies
- Memory efficient: Uses
__slots__and lazy evaluation - Composable: Handles nested slicing operations efficiently
Installation
pip install lazily-sliced
Usage
from lazily_sliced import LazilySliced
# Create from any sequence
data = list(range(1000))
lazy = LazilySliced(data, slice(100, 200))
# Standard sequence operations work
print(len(lazy)) # 100
print(lazy[10]) # 110
print(105 in lazy) # True
# Supports nested slicing
subset = lazy[10:20:2]
print(subset) # LazilySliced([110, 112, 114, 116, 118])
for item in lazy:
print(item)
When to Use
Ideal for:
- Working with large sequences where you need small slices
- Memory-constrained environments
- Chaining multiple slicing operations
- Cases where immediate data copying is expensive
Performance Characteristics
| Operation | Time Complexity | Notes |
|---|---|---|
len() |
O(1) | |
| Index access | O(1) | |
| Iteration | O(n) | Proportional to slice size |
in check |
O(n) | Worst case scans entire slice |
| Memory usage | O(1) | Constant overhead |
Limitations
- Read-only (doesn't support item assignment)
- Underlying sequence must support integer indexing
- Slices must be within bounds of original sequence
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Release files for lazily-sliced 0.1.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lazily_sliced-0.1.0a0.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lazily_sliced-0.1.0a0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 6.4 kB
Release files / lazily_sliced-0.1.0a0.tar.gz
| Download URL | lazily_sliced-0.1.0a0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbb86ce6a1c42c2d444bcce427a175eba4d586d5def83d6fc3cd4c6a28e5cfb7
|
|
BLAKE2b-256 checksum How to use checksums |
099cff6554fe0794093067315ce342b87c68418d13e67bd3be036707bad576da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Release files / lazily_sliced-0.1.0a0-py2.py3-none-any.whl
| Download URL | lazily_sliced-0.1.0a0-py2.py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2ab4fcd6b4a87d38c904f126c4ed454281f78eba345c7242b051a9c41c33d314
|
|
BLAKE2b-256 checksum How to use checksums |
25d99a3eae40fd40be56dc8414db3ff6c34897512d6e75200c8e26717d8a53b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|