Skip to main content

Extra data structures for pyrsistent

Project description

docs-badge coverage-badge tests-badge mypy-badge pypi-badge

Extra data structures for pyrsistent

Below are examples of common usage patterns for some of the structures and features. More information and full documentation for all data structures is available in the documentation.

PSequence

Persistent sequences implemented with finger trees, with \(O(\log{n})\) merge/split/lookup and \(O(1)\) access at both ends.

>>> from pyrsistent_extras import psequence
>>> seq1 = psequence([1, 2, 3])
>>> seq1
psequence([1, 2, 3])
>>> seq2 = seq1.append(4)
>>> seq2
psequence([1, 2, 3, 4])
>>> seq3 = seq1 + seq2
>>> seq3
psequence([1, 2, 3, 1, 2, 3, 4])
>>> seq1
psequence([1, 2, 3])
>>> seq3[3]
1
>>> seq3[2:5]
psequence([3, 1, 2])
>>> seq1.set(1, 99)
psequence([1, 99, 3])

PHeap

Persistent heaps implemented with binomial heaps, with \(O(1)\) findMin/insert and \(O(\log{n})\) merge/deleteMin. Comes in two flavors: PMinHeap and PMaxHeap.

>>> from pyrsistent_extras import pminheap
>>> heap1 = pminheap([(1,'a'), (2,'b')])
>>> heap1
pminheap([(1, 'a'), (2, 'b')])
>>> heap2 = heap1.push(3,'c')
>>> heap2
pminheap([(1, 'a'), (2, 'b'), (3, 'c')])
>>> heap3 = heap1 + heap2
>>> heap3
pminheap([(1, 'a'), (1, 'a'), (2, 'b'), (2, 'b'), (3, 'c')])
>>> key, value, heap4 = heap3.pop()
>>> (key, value)
(1, 'a')
>>> heap4
pminheap([(1, 'a'), (2, 'b'), (2, 'b'), (3, 'c')])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrsistent-extras-0.1.1.tar.gz (49.2 kB view hashes)

Uploaded Source

Built Distributions

pyrsistent_extras-0.1.1-cp312-abi3-win_amd64.whl (78.8 kB view hashes)

Uploaded CPython 3.12+ Windows x86-64

pyrsistent_extras-0.1.1-cp312-abi3-win32.whl (69.3 kB view hashes)

Uploaded CPython 3.12+ Windows x86

pyrsistent_extras-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (90.9 kB view hashes)

Uploaded CPython 3.12+ manylinux: glibc 2.17+ ARM64

pyrsistent_extras-0.1.1-cp312-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (92.5 kB view hashes)

Uploaded CPython 3.12+ manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyrsistent_extras-0.1.1-cp312-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (97.7 kB view hashes)

Uploaded CPython 3.12+ manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyrsistent_extras-0.1.1-cp312-abi3-macosx_10_9_universal2.whl (112.5 kB view hashes)

Uploaded CPython 3.12+ macOS 10.9+ universal2 (ARM64, x86-64)

pyrsistent_extras-0.1.1-cp311-cp311-win_amd64.whl (78.4 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyrsistent_extras-0.1.1-cp311-cp311-win32.whl (69.1 kB view hashes)

Uploaded CPython 3.11 Windows x86

pyrsistent_extras-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (90.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyrsistent_extras-0.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (92.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyrsistent_extras-0.1.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (97.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyrsistent_extras-0.1.1-cp311-cp311-macosx_10_9_universal2.whl (112.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

pyrsistent_extras-0.1.1-cp310-cp310-win_amd64.whl (78.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyrsistent_extras-0.1.1-cp310-cp310-win32.whl (69.1 kB view hashes)

Uploaded CPython 3.10 Windows x86

pyrsistent_extras-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (91.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyrsistent_extras-0.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (92.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyrsistent_extras-0.1.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (97.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyrsistent_extras-0.1.1-cp310-cp310-macosx_10_9_universal2.whl (112.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

pyrsistent_extras-0.1.1-cp39-cp39-win_amd64.whl (78.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyrsistent_extras-0.1.1-cp39-cp39-win32.whl (69.1 kB view hashes)

Uploaded CPython 3.9 Windows x86

pyrsistent_extras-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (91.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyrsistent_extras-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (92.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyrsistent_extras-0.1.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (97.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyrsistent_extras-0.1.1-cp39-cp39-macosx_10_9_universal2.whl (112.5 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

pyrsistent_extras-0.1.1-cp38-cp38-win_amd64.whl (78.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyrsistent_extras-0.1.1-cp38-cp38-win32.whl (69.1 kB view hashes)

Uploaded CPython 3.8 Windows x86

pyrsistent_extras-0.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (91.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyrsistent_extras-0.1.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (92.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

pyrsistent_extras-0.1.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (97.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

pyrsistent_extras-0.1.1-cp38-cp38-macosx_10_9_universal2.whl (112.4 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page