Skip to main content

Svector

Svector (pronounced Swag-tor) provides extension methods to pyrsistent data structures. Easily chain your methods confidently with tons of additional methods. Leverage the latest mypy features to spot errors during coding.

pypi python Build Status

pip install svector

Immutable list replacement for python. With postfix methods for easy functional programming.

Quick Start

With mypy installed, easily spot errors when you call the wrong methods on your sequence.

from svector import Svector

many_strings = Svector.of(["Lucy, Damion, Jon"])  # Svector[str]
many_strings.sum()  # Mypy errors with 'Invalid self argument'. You can't sum a sequence of strings!

many_nums = Svector.of([1, 1.2])
assert many_nums.sum() == 2.2  # ok!

class CannotSortMe:
    def __init__(self, value: int):
        self.value: int = value

stuff = Svector.of([CannotSortMe(value=1), CannotSortMe(value=1)])
stuff.sort_by(lambda x: x)  # Mypy errors with 'Cannot be "CannotSortMe"'. You can't sort by the class itself
stuff.sort_by(lambda x: x.value)  # ok! You can sort by the value

Svector.of([{"i am a dict": "value"}]).distinct_by(
    lambda x: x
)  # Mypy errors with 'Cannot be Dict[str, str]. You can't hash a dict itself

Svector provides methods that you can chain easily for easier data processing.

from svector import Svector

Svector.of([-1, 0, 1]).map(
    lambda x: x if x >= 0 else None).flatten_option()  # Mypy infers Svector[int] correctly

result = (
    Svector.of(i for i in range(5000))
    .map(lambda x: (x % 3, x))
    .filter(lambda x: x[0] == 0)
    .for_each_enumerate(lambda idx, element: print(f"{idx}: {element}"))
    .take(5)
)

Metadata

Release files for svector 0.1.1

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

Source distribution (sdist)

Source distribution for svector 0.1.1
File Size Uploaded Provenance
svector-0.1.1.tar.gz 9.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for svector 0.1.1
File Interpreter ABI Platform
svector-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.2 kB

Release files / svector-0.1.1.tar.gz

Download URL svector-0.1.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
211398c1a780f85660e271b8ade41fe6ce8a433a5ab0edb38216f732a42e556b
BLAKE2b-256 checksum
How to use checksums
431ae099dca452b1944209c1db9db07882a7ea3e1523379a3be973dc6b116860
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / svector-0.1.1-py3-none-any.whl

Download URL svector-0.1.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35bc365087e0f4c7b810d4a6091829a3315da7d50aeb37a0591c22a0e61e5592
BLAKE2b-256 checksum
How to use checksums
7979b8ccf91b0996ccec5bfc21649d1a22a428db4761a39446c7461c33b64392
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Security for svector 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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