Skip to main content

Splynters v0.1.2

A Python package for efficient compression of sparse bitmaps

Splynters is a Python wrapping over the splinter-rs library for zero-copy querying of compressed bitmaps.

We support Python >=3.8 on recent versions of Windows, MacOS, and manylinux.

We also provide benchmarking against the PyRoaring implementation of Roaring BitMaps, which you can view in the python/benchmarking.ipynb file and run for yourself with run_all_benchmarks.py.

This package can be installed from PyPI using

pip install splynters

Examples

Create a Splinter

Splinter bitmaps can be created from Python iterables, as follows:

import splynters
from splynters import Splinter

data = [1, 5, 789423, 23]
s = Splinter.from_list(data)

Add and remove elements

Elements can be added or removed in the same manner as Python sets: note that we provide both a .remove() method which throws an error if it does not find such an element, as well as a .discard() method which fails silently in such an event.

s.add(6)

s.remove(5)

# will throw an error! uncomment to see:
# > KeyError: 'remove() could not find the key 99 in the splinter. For a fault-tolerant alternative to remove(), consider discard()'
# s.remove(99) 

s.discard(99) # will fail silently

Check for an element

We can check for the presence of an element using the .contains() method. This can be used for either single elements or iterables of elements, and will return either a single boolean or array of booleans.

Note that we also provide a .contains_many_parallel() method designed to speed up the process of searching for the presence of many elements at once by parallelizing the search. Note that the regular .contains() method is fast enough that the parallel version is not likely to be faster unless you are searching for more than 10,000 elements.

data = [1, 5, 789423, 23]
s = Splinter.from_list(data)

s.add(6)
s.remove(5)

assert(s.contains(1))
assert(not s.contains(99))
assert(s.contains([1, 23, 789423]))

We can also do the same for single elements using Python's in operator:

assert(1 in s)
assert(not 99 in s)

And can also access elements or ranges of elements using Python's slice syntax, with negative numbers indicating indices counting from the end:

assert(s[2] == 23) # access the third element
assert(s[-1] == 789423) # access the last element
assert(s[1:] == [6, 23, 789423]) # access all elements starting from the second
assert(s[0::2] == [1, 23]) # access every other element starting from the first
assert(s[::-1] == [789423, 23, 6, 1]) # access all elements backwards

Set operations

Splinters support all set operations, including bitwise operations:

data1 = [1, 5, 6, 789423, 23]
data2 = [1, 5, 789423, 23, 42]

s1 = Splinter.from_list(data1)
s2 = Splinter.from_list(data2)

splinter_intersection = s1 & s2
splinter_union = s1 | s2
splinter_xor = s1 ^ s2
splinter_sub = s1 - s2

assert(splinter_intersection.to_list() == [1, 5, 23, 789423])
assert(splinter_union.to_list() == [1, 5, 6, 23, 42, 789423]) # note that the output order will be sorted low to high! not necessarily the same as the input order
assert(splinter_xor.to_list() == [6, 42]) 
assert(splinter_sub.to_list() == [6])

As well as bitwise assignments:

s1 = Splinter.from_list(data1)
s1 &= s2
assert(s1.to_list() == [1, 5, 23, 789423])

s1 = Splinter.from_list(data1)
s1 |= s2
assert(s1.to_list() == [1, 5, 6, 23, 42, 789423])

s1 = Splinter.from_list(data1)
s1 ^= s2
assert(s1.to_list() == [6, 42])

s1 = Splinter.from_list(data1)
s1 -= s2
assert(s1.to_list() == [6])

And also explicit set operations:

data1 = [1, 5, 789423, 23, 42]
data2 = [1, 5, 789423, 42]
data3 = [2, 83, 98798]

s1 = Splinter.from_list(data1)
s2 = Splinter.from_list(data2)
s3 = Splinter.from_list(data3)

s1.isdisjoint(s3)
s2.issubset(s1)
s1.issuperset(s2)

And it also supports comparison operators for equality, subsets, and proper subsets:

data1 = [1, 5, 6, 789423, 23]
data2 = [1, 5, 789423, 23, 42]
data3 = [1, 5, 789423, 42]

s1 = Splinter.from_list(data1)
s2 = Splinter.from_list(data2)
s3 = Splinter.from_list(data3)

assert(not s1==s2) # s1 and s2 are not equal
assert(s1 != s2)

assert(not s1 <= s2) # s1 is not a subset of s2
assert(not s1 < s2) # as a consequence of the above, s1 is also not a proper subset of s2
assert(s3 <= s2) # but s3 is a subset of s2
assert(s3 < s2) # and would you look at that, it's also a proper subset!

assert(not s1 >= s2) # s2 is not a subset of s1
assert(not s1 > s2) # s2 is not a proper subset of s1

Compression Optimization

A Splinter object can be further compressed to its minimum memory footprint using the .optimize() method.

This operation is computationally expensive, so it should be called before serializing data or after very large changes in order to reduce size in memory. It is not recommended to call this in a tight loop or after small changes.

data = [1, 5, 789423, 23]
s = Splinter.from_list(data)

# ...
# a lot of changes
# ...

s.optimize()

Serialization, Deserialization, and Pickling

A Splinter object can be serialized to bytes using the .to_bytes() method, and deserialized using .from_bytes().

data = [1, 5, 789423, 23]
s = Splinter.from_list(data)

b = s.to_bytes()

s_but_fancy_this_time = Splinter.from_bytes(b)
assert(s == s_but_fancy_this_time)

In addition, a splinter object's basic data can be displayed simply by printing it (or in a REPL, using its name), and it can be decompressed to show its internal elements using .to_list():

print(s)
# > SplinterWrapper(len = 4, compressed_byte_size = 35)

print(s.to_list())
# > [1, 5, 23, 789423]

Splinter also implements getstate and setstate, so that Splinters can be serialized and deserialized with Pickle.

import pickle

s = Splinter.from_list([1, 5, 23, 789423])

pickled_s = pickle.dumps(s)
unpickled_s = pickle.loads(pickled_s)
assert(s == unpickled_s)

Dependencies

At present, splynters has no additional dependencies.

Roadmap

  • Keep splynters up to date with the splinter-rs API and capabilities
  • Benchmark runtime performance of major operations against PyRoaring
  • Add optional numpy dependency to enable faster serialization to and from numpy arrays, Pandas series, and Polars series.

Metadata

Release files for splynters 0.1.2

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

Source distribution (sdist)

Source distribution for splynters 0.1.2
File Size Uploaded Provenance
splynters-0.1.2.tar.gz 23.2 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for splynters 0.1.2
File
splynters-0.1.2-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
splynters-0.1.2-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
splynters-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details
splynters-0.1.2-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
splynters-0.1.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
splynters-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details
splynters-0.1.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
splynters-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
splynters-0.1.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
splynters-0.1.2-cp311-cp311-macosx_10_12_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64 Details
splynters-0.1.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
splynters-0.1.2-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
splynters-0.1.2-cp310-cp310-macosx_10_12_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.12+ x86-64 Details
splynters-0.1.2-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
splynters-0.1.2-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
splynters-0.1.2-cp39-cp39-macosx_10_12_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.12+ x86-64 Details
splynters-0.1.2-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
splynters-0.1.2-cp38-cp38-macosx_11_0_arm64.whl CPython 3.8 CPython 3.8 macOS 11.0+ ARM64 Details
splynters-0.1.2-cp38-cp38-macosx_10_12_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.12+ x86-64 Details

Total release size: 14.0 MB

Release files / splynters-0.1.2.tar.gz

Download URL splynters-0.1.2.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
88166d63f18a191cd6af865030438f2936945b40ce29646a25bd01d7c4c354a3
BLAKE2b-256 checksum
How to use checksums
9944428e87455fd21b9ccda5d65dc9cf5289b8c81d11cae4aa50e650ef93bf5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp313-cp313-win_amd64.whl

Download URL splynters-0.1.2-cp313-cp313-win_amd64.whl
Size 705.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
e532fbe062732f2b890fa9114c4d5ee85dacd7b1b183381d25ea5f3dd2bda6c8
BLAKE2b-256 checksum
How to use checksums
05ee7b1fd1852fb09f8e4744bfeb332d392d303f1e72d36b0527140a0a37b680
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp313-cp313-macosx_11_0_arm64.whl

Download URL splynters-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Size 700.6 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
eaf940322eb62d44337b2bb45a8606db218f74047fbfecf8ec6ec662b4e8a764
BLAKE2b-256 checksum
How to use checksums
863c0e0646120cca717ee1334d90390d4ad023cd8d39d34248a435cb2fc3d563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl

Download URL splynters-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl
Size 777.3 kB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3e5aeedd2643126cd55968593dfdd9ebbc0931417b9cedaf98ad1c0ccb97e9f6
BLAKE2b-256 checksum
How to use checksums
fc1cc2b384d0ee18b235d11482bda94bf373c3318fae7eeaa62ae51119289cd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp312-cp312-win_amd64.whl

Download URL splynters-0.1.2-cp312-cp312-win_amd64.whl
Size 705.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
85d8df0057bfb54f7dfe1a5a5dbc5d0ff0034ef396943768b2d006104005c635
BLAKE2b-256 checksum
How to use checksums
01b9eacf6202cd6f29e06172eebb589484da5b2f69a2cdaee4547637eef4efae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL splynters-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Size 700.5 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a0b4d24855daab081c96549745cb7005d49093fab6b8160f4f3ccc24f20d8d95
BLAKE2b-256 checksum
How to use checksums
b583dea76998aa9112492dafda5d8c20b8dabda27378300dc9d13397edaedb27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl

Download URL splynters-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl
Size 777.4 kB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
eca8cf4c7742b410c5dc04d4ba144efed9c5d870090dd6d13beab972068ffd83
BLAKE2b-256 checksum
How to use checksums
03a31d800ba9c0c84e58008e56d8fed7bcf89ab79844395c021545de40ab95a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp311-cp311-win_amd64.whl

Download URL splynters-0.1.2-cp311-cp311-win_amd64.whl
Size 702.6 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
41021fef01d8e6fc2a4f4411610466a3b3f3a76f5de56b2d040772bc18cac34f
BLAKE2b-256 checksum
How to use checksums
97ce610144de642ba6304b0f983aa9869e781c5385d02d56a828378c830c7e98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL splynters-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl
Size 825.8 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
52384c76c01b3cfaf657ff1d9545243aca9cd0101b6517f04f2edc78ffc63610
BLAKE2b-256 checksum
How to use checksums
1f89af627998a3e767dcc43f8b945f80f5aad5b3b1876aca82604a73de75e16c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL splynters-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Size 700.6 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d50b5eecccc70ef9f360d2292d3cd675c1fd5b8bdb28019f25f58810bcab97b9
BLAKE2b-256 checksum
How to use checksums
0ae1d15cf98d33dc0f19fa7800818b7888a79698761c2b62a028ecb7f632da2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp311-cp311-macosx_10_12_x86_64.whl

Download URL splynters-0.1.2-cp311-cp311-macosx_10_12_x86_64.whl
Size 779.5 kB
Tags CPython 3.11 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
419bf6d1e6bea2eda0d3255a293ab9cf49313357d61525bbd0a9930ffb7491fb
BLAKE2b-256 checksum
How to use checksums
043a22c56a7fedd2dd8a24a1fae90dac4960c17d0c6b5325163487f458a9452c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp310-cp310-win_amd64.whl

Download URL splynters-0.1.2-cp310-cp310-win_amd64.whl
Size 701.5 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
d55d6f1cc5c06ab7d48709c22069fb9f940d15b045d1cc556f0c845c911c58d3
BLAKE2b-256 checksum
How to use checksums
97dd96159f158c804fc28c2a3969201d09aca45e9d8ec7d9238a6ec7efb1f283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp310-cp310-macosx_11_0_arm64.whl

Download URL splynters-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Size 700.6 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
01de8c95f05f1f46990da42f8b7fd3b38c10601d22f5c2205551e1ec90db0a0e
BLAKE2b-256 checksum
How to use checksums
40950b2b79e5c9ad4e875db22d0343298b7a0431f34b9d94601c5f9ab9aec4e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp310-cp310-macosx_10_12_x86_64.whl

Download URL splynters-0.1.2-cp310-cp310-macosx_10_12_x86_64.whl
Size 779.6 kB
Tags CPython 3.10 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
eaae1e6430cd3b20b689c2252fe37f4812374f73e57ed165ae935aef0d7752b2
BLAKE2b-256 checksum
How to use checksums
26360b5c6ba6c641bf788aa87e8e0baa3845c679c63efe8d2c8f4caeb520a59d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp39-cp39-win_amd64.whl

Download URL splynters-0.1.2-cp39-cp39-win_amd64.whl
Size 703.2 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
ae78c4b7d3cb652b12ec0621a1b454fb7fc7f89600e435b787eafe3b0e6cf317
BLAKE2b-256 checksum
How to use checksums
768e1bb4d879897484ff6d8cbcedf64ebaffec3a2398bbbe6f279948246ebe4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp39-cp39-macosx_11_0_arm64.whl

Download URL splynters-0.1.2-cp39-cp39-macosx_11_0_arm64.whl
Size 702.7 kB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a44a0aa1bc14aecc0046cae9480aee04cf896f34e5cd83369fd95eea982670f6
BLAKE2b-256 checksum
How to use checksums
28452b43950bfa5ac49bca97025d234aebed7e16411dcde31491d761beb8ba28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp39-cp39-macosx_10_12_x86_64.whl

Download URL splynters-0.1.2-cp39-cp39-macosx_10_12_x86_64.whl
Size 782.3 kB
Tags CPython 3.9 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
480bc953242fd2ad18755b34e30a86faba7e0295c66033f8bc9c7cd84d59ff6a
BLAKE2b-256 checksum
How to use checksums
8ecad3abe815323be4d2aa567fedd9edf826bb0f2f2eeb2eb94c6a23fbe52652
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp38-cp38-win_amd64.whl

Download URL splynters-0.1.2-cp38-cp38-win_amd64.whl
Size 703.1 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
efd67a1097ddcb2e2ce9674a810d464b90c52cb9ed2f3d9dd472186c62dc80e5
BLAKE2b-256 checksum
How to use checksums
90a6ced41666e311fbd77c95f09f6780d623b283b3697487fe06bfd9ab15349f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp38-cp38-macosx_11_0_arm64.whl

Download URL splynters-0.1.2-cp38-cp38-macosx_11_0_arm64.whl
Size 702.1 kB
Tags CPython 3.8 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
49fbc3331dabd22dcd04da03e9c868112be8b3fd5c0063c4a719b4612ac50902
BLAKE2b-256 checksum
How to use checksums
4167e36abf5ba5d195f45d6397163dc4f9738b45e59a58453fbf9af847d51316
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Release files / splynters-0.1.2-cp38-cp38-macosx_10_12_x86_64.whl

Download URL splynters-0.1.2-cp38-cp38-macosx_10_12_x86_64.whl
Size 781.9 kB
Tags CPython 3.8 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
056b44d49f76dfcd2aea7b9e44e15259f61ebdaa8f97ce8e53e9939b76655d01
BLAKE2b-256 checksum
How to use checksums
ca7f5bd605c5b6387e9c9b5ff9b2217c740e5cc74aca9c542f02f5b4f8ac0c4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.9.6

Security for splynters 0.1.2

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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