Skip to main content

PyPI-Server Unit tests

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 CompressedLists to custom data types.

Note

This project has been set up using BiocSetup and PyScaffold.

Release files for compressed-lists 0.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compressed-lists 0.4.5
File Size Uploaded
compressed_lists-0.4.5.tar.gz 38.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for compressed-lists 0.4.5
File Interpreter ABI Platform
compressed_lists-0.4.5-py3-none-any.whl Python 3 none any Details

Total release size: 58.2 kB

Release files / compressed_lists-0.4.5.tar.gz

Download URL compressed_lists-0.4.5.tar.gz
Size 38.0 kB
Tags Source
SHA-256 checksum
How to use checksums
48d3861e0ea973995bdd6ab8ce7a4248f9fb56e94dcb8a0726c4d6fc96da93d1
BLAKE2b-256 checksum
How to use checksums
2652b7cc51eaff17625521af66b67299d00d5f48af2a54381a72ffb4d4ae89b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 14, 2026.

Transparency log

Release files / compressed_lists-0.4.5-py3-none-any.whl

Download URL compressed_lists-0.4.5-py3-none-any.whl
Size 20.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f289abd185fd6404bec69287f5a759b93335b8eb0a9e7830b29e79d0ac7aa0ba
BLAKE2b-256 checksum
How to use checksums
f7700fbc2d5f23233a9c570a1aa26068b678c1f3b5ffa5fa7bca09270fb40a17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.5 This release

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page