Skip to main content

isplit logo

Lazy, typed string splitting helpers for Python, backed by Rust.

PyPI Python versions CI MIT License

isplit scans a string once and yields pieces as soon as separators are found. It is useful for tokenizer-style code where callers want to consume tokens lazily instead of allocating the whole split result up front.

The iterator implementation is backed by a small PyO3 Rust extension when available, with the original pure-Python implementation kept as a fallback.

Installation

python -m pip install isplit-rs

The PyPI distribution is named isplit-rs, while the Python package is imported as isplit.

Quick start

from isplit import irsplit, isplit

list(isplit("A+B+C+D", "+"))
# ["A", "B", "C", "D"]

list(isplit("AAA,,BBB", ",,"))
# ["AAA", "BBB"]

list(irsplit("A+B+C+D", "+"))
# ["D", "C", "B", "A"]

Or consume pieces lazily:

from isplit import isplit

for token in isplit("AAA,BBB,CCC", ","):
    print(token)

Why isplit?

Feature What it gives you
Lazy iteration Consume split pieces one at a time
Forward and reverse splits Use isplit or irsplit depending on scan direction
Rust acceleration Use the PyO3 extension when available
Pure-Python fallback Keep imports working even without the extension
Typed package Ship a py.typed marker for type checkers

Performance

isplit is designed for lazy, partial consumption. When you need every piece as a list, CPython's built-in str.split is usually the best choice. When you only need the first few pieces from a larger string, isplit can stop before splitting the rest of the input.

One local CPython 3.12 / macOS arm64 run, extracting only the first field with the first separator at index 8:

Input size split(",")[0] split(",", 1)[0] partition(",")[0] next(isplit(...))
~1 MB 1774.0 us 14.6 us 16.2 us 0.3 us
~100 KB 140.7 us 1.9 us 2.0 us 0.3 us
~10 KB 13.4 us 0.8 us 0.6 us 0.3 us
~1 KB 1.8 us 0.4 us 0.3 us 0.3 us

Performance chart comparing partial str.split and isplit

In other words, isplit helps most when it avoids unnecessary work. For small strings, the difference is tiny; for larger strings, avoiding a full split can matter.

Run the benchmark locally:

uv run python scripts/benchmark_split.py

API

isplit(text: str, sep: str) -> Iterator[str]
irsplit(text: str, sep: str) -> Iterator[str]
  • isplit(text, sep) yields pieces from left to right.
  • irsplit(text, sep) yields pieces from right to left.

Both functions follow str.split semantics for non-empty separators and raise ValueError when sep is empty.

Verify Rust acceleration

Installed wheels include the native Rust extension. To check that your environment is using it:

python - <<'PY'
import isplit._rust as rust

print(rust.__file__)
print(list(rust.isplit("A+B+C", "+")))
PY

The printed path should point to a compiled extension such as isplit/_rust.abi3.so on Linux/macOS or isplit/_rust.pyd on Windows.

Release files for isplit-rs 0.3.0

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

Source distribution (sdist)

Source distribution for isplit-rs 0.3.0
File Size Uploaded
isplit_rs-0.3.0.tar.gz 13.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for isplit-rs 0.3.0
File Interpreter ABI Platform
isplit_rs-0.3.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
isplit_rs-0.3.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details
isplit_rs-0.3.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details

Total release size: 637.8 kB

Release files / isplit_rs-0.3.0.tar.gz

Download URL isplit_rs-0.3.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e7f10b7e97700e3b412f85776735a8f4d968a79d1e92e16ac0b14de259967edd
BLAKE2b-256 checksum
How to use checksums
ef9440b3e892ecda9123575cd18e09054816fb534feca7f069a08773e1d4667d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 15, 2026.

Transparency log

Release files / isplit_rs-0.3.0-cp39-abi3-win_amd64.whl

Download URL isplit_rs-0.3.0-cp39-abi3-win_amd64.whl
Size 127.8 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0b45c8a824e6ed0cfadda2a556398ed6b33253c891fcccd82f60064af33a4a65
BLAKE2b-256 checksum
How to use checksums
74a123ce7ad3d7cd980de2f15b3c430ca14398376a2b8d290d9de52c51dabe8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 15, 2026.

Transparency log

Release files / isplit_rs-0.3.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL isplit_rs-0.3.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 267.0 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
c4575ee4a693ee57dadaeb50723a3c585697f7bb14ab24ea74e25221b1a49478
BLAKE2b-256 checksum
How to use checksums
601ec902e58e838e099b6754b1d15f5a55526af00e78ae49d8541122035fa1b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 15, 2026.

Transparency log

Release files / isplit_rs-0.3.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL isplit_rs-0.3.0-cp39-abi3-macosx_11_0_arm64.whl
Size 229.7 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c0ae83e0737cec21a6d6372be06e2d79d4135aae9c76427100ca4952a40e8486
BLAKE2b-256 checksum
How to use checksums
118a6e4dfce11c0e88814a9bf2a968c31f6317c0ad05d27f6c1f54f66fc8d8b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

4 release files

0.2.0

4 release files

0.1.0

4 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