Memory-efficient container for list-like objects
Project description
CompressedList Implementation in Python
A Python implementation of the CompressedList class from R/Bioconductor for memory-efficient list-like objects.
CompressedList is a memory-efficient container for list-like objects. Instead of storing each list element separately, it concatenates all elements into a single vector-like object and maintains information about where each original element begins and ends. This approach is significantly more memory-efficient than standard lists, especially when dealing with many list elements.
Install
To get started, install the package from PyPI
pip install compressed-lists
Usage
from compressed_lists import CompressedIntegerList, CompressedStringList, Partitioning
# Create a CompressedIntegerList
int_data = [[1, 2, 3], [4, 5], [6, 7, 8, 9]]
names = ["A", "B", "C"]
int_list = CompressedIntegerList.from_list(int_data, names)
# Access elements
print(int_list[0]) # [1, 2, 3]
print(int_list["B"]) # [4, 5]
print(int_list[1:3]) # Slice of elements
# Apply a function to each element
squared = int_list.lapply(lambda x: [i**2 for i in x])
print(squared[0]) # [1, 4, 9]
# Convert to a regular Python list
regular_list = int_list.to_list()
# Create a CompressedStringList from lengths
import biocutils as ut
char_data = ut.StringList(["apple", "banana", "cherry", "date", "elderberry", "fig"])
char_list = CompressedStringList(char_data, partitioning=Partitioning.from_lengths([2,3,1]))
print(char_list)
Partitioning
The Partitioning class handles the information about where each element begins and ends in the concatenated data. It allows for efficient extraction of elements without storing each element separately.
from compressed_lists import Partitioning
# Create partitioning from end positions
ends = [3, 5, 10]
names = ["A", "B", "C"]
part = Partitioning(ends, names)
# Get partition range for an element
start, end = part[1] # Returns (3, 5)
[!NOTE]
Check out the documentation for available compressed list implementations and extending
CompressedListsto custom data types.
Note
This project has been set up using BiocSetup and PyScaffold.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compressed_lists-0.4.3.tar.gz.
File metadata
- Download URL: compressed_lists-0.4.3.tar.gz
- Upload date:
- Size: 37.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
223603b710e11fb58cca2f92c9fda31b1fe9e70fde161a338e585fece560688f
|
|
| MD5 |
55d2658823888760810e4cd6d6d1ad38
|
|
| BLAKE2b-256 |
2e8d3115b5c22041103bab0b0a08dde086f503c468f9e4a733505262e5348109
|
Provenance
The following attestation bundles were made for compressed_lists-0.4.3.tar.gz:
Publisher:
publish-pypi.yml on BiocPy/compressed-lists
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compressed_lists-0.4.3.tar.gz -
Subject digest:
223603b710e11fb58cca2f92c9fda31b1fe9e70fde161a338e585fece560688f - Sigstore transparency entry: 789033412
- Sigstore integration time:
-
Permalink:
BiocPy/compressed-lists@69e0170a9583f871913c2c24980ad103e4493760 -
Branch / Tag:
refs/tags/0.4.3 - Owner: https://github.com/BiocPy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@69e0170a9583f871913c2c24980ad103e4493760 -
Trigger Event:
push
-
Statement type:
File details
Details for the file compressed_lists-0.4.3-py3-none-any.whl.
File metadata
- Download URL: compressed_lists-0.4.3-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab18c24d1affaccc5e5f195b710d179d9be2d9e47052fe9b9b92139428aed4f5
|
|
| MD5 |
a6e0f75a404cdd3b5af0de4f4650bd52
|
|
| BLAKE2b-256 |
44687fd61af4bda7172053d859496b5ed03757faf1488ec97a28e32d50624583
|
Provenance
The following attestation bundles were made for compressed_lists-0.4.3-py3-none-any.whl:
Publisher:
publish-pypi.yml on BiocPy/compressed-lists
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compressed_lists-0.4.3-py3-none-any.whl -
Subject digest:
ab18c24d1affaccc5e5f195b710d179d9be2d9e47052fe9b9b92139428aed4f5 - Sigstore transparency entry: 789033421
- Sigstore integration time:
-
Permalink:
BiocPy/compressed-lists@69e0170a9583f871913c2c24980ad103e4493760 -
Branch / Tag:
refs/tags/0.4.3 - Owner: https://github.com/BiocPy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@69e0170a9583f871913c2c24980ad103e4493760 -
Trigger Event:
push
-
Statement type: