Python binding for the FastParse Tree-sitter parser library with bundled native runtime
Project description
FastParse Python Binding
Small ctypes binding for the FastParse native C library.
The binding keeps the same design boundary as the native library:
- Python owns file I/O.
- Python passes bytes already loaded in RAM.
- FastParse returns JSON, CSV, MessagePack binary, diagnostics, or stats in RAM.
- FastParse can execute Tree-sitter queries and return matches/captures in RAM.
- Python copies the returned native buffer and frees the native result.
Install
From PyPI, once the package is published:
pip install --pre fastparse
From a downloaded wheel:
pip install fastparse-0.1.0rc17-py3-none-macosx_11_0_arm64.whl
The wheel includes the native library for its platform and py.typed markers for type-aware tooling, so normal users do not need FASTPARSE_LIBRARY_PATH.
Quick Use
from fastparse import FastParse, Field, OutputFormat, ParseOptions
parser = FastParse()
source = b"class Demo { void run() {} }"
result = parser.parse_bytes(
source,
ParseOptions(
language="java",
output_format=OutputFormat.JSON,
fields=Field.RULE | Field.TEXT | Field.BYTE_RANGE,
),
)
print(result.node_count)
print(result.json())
Tree-sitter query output:
from fastparse import QueryOptions
query_result = parser.query_text(
"class Demo { void run() {} }",
"(method_declaration name: (identifier) @method.name) @method",
QueryOptions(
language="java",
output_format=OutputFormat.JSON,
fields=Field.CAPTURE_NAME | Field.RULE | Field.TEXT | Field.RANGE | Field.BYTE_RANGE,
),
)
print(query_result.json())
Binary MessagePack output:
result = parser.parse_bytes(
source,
language="java",
output_format="binary",
fields=["rule", "text", "byte_range"],
)
print(result.node_count)
print(result.data) # MessagePack bytes
Decode binary output into Python dataclasses:
document = result.binary_document()
print(document.nodes[0].rule)
print(document.nodes[0].text)
If the caller only needs node/output counts and does not need to copy the generated JSON/CSV into Python:
summary = parser.parse_bytes_summary(
source,
language="java",
output_format="json",
)
print(summary.node_count)
print(summary.output_length)
Use FASTPARSE_LIBRARY_PATH to point at a specific native library:
FASTPARSE_LIBRARY_PATH=/path/to/libfastparse.dylib python your_script.py
Examples
From the repository root:
python3 examples/python/03_binary_decode/binary_decode.py
python3 examples/python/04_inventory_to_sqlite/inventory_to_sqlite.py --workers 12
python3 examples/python/05_diagnostics_scan/diagnostics_scan.py /path/to/java/root --glob "*.java" --workers 12
04_inventory_to_sqlite is the enterprise pattern for high-throughput work:
the parent Python app reads files, uses threads, decodes binary output into
dataclasses, and writes SQLite tables outside the native library.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastparse-0.1.0rc28-py3-none-win_amd64.whl.
File metadata
- Download URL: fastparse-0.1.0rc28-py3-none-win_amd64.whl
- Upload date:
- Size: 144.1 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31f302adaf5de32c00153b85f221feba70ca850a59daa53cc348f1c7d9e431e6
|
|
| MD5 |
5881be731e646b9cef60cc3963cec344
|
|
| BLAKE2b-256 |
2a98de1423c564515bed306a998fbd311f6fd0ba79d16691ca97bbddfe979197
|
Provenance
The following attestation bundles were made for fastparse-0.1.0rc28-py3-none-win_amd64.whl:
Publisher:
release.yml on natan-sysview/fast_parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastparse-0.1.0rc28-py3-none-win_amd64.whl -
Subject digest:
31f302adaf5de32c00153b85f221feba70ca850a59daa53cc348f1c7d9e431e6 - Sigstore transparency entry: 2026161057
- Sigstore integration time:
-
Permalink:
natan-sysview/fast_parser@d2966fd4eaeec117c034db2e697b0280f82482bf -
Branch / Tag:
refs/tags/v0.1.0-preview.28 - Owner: https://github.com/natan-sysview
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d2966fd4eaeec117c034db2e697b0280f82482bf -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastparse-0.1.0rc28-py3-none-manylinux2014_x86_64.whl.
File metadata
- Download URL: fastparse-0.1.0rc28-py3-none-manylinux2014_x86_64.whl
- Upload date:
- Size: 191.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ef77b04e98599c414b234f8d5e8d35ceba3fc5fd907120033dd513cdb72625a
|
|
| MD5 |
411fc52390d211ecb1ca58abcf93882d
|
|
| BLAKE2b-256 |
5493acc055af5d658e05c13f700a851e5cc76a79274471a09ddabc82dce8c40d
|
Provenance
The following attestation bundles were made for fastparse-0.1.0rc28-py3-none-manylinux2014_x86_64.whl:
Publisher:
release.yml on natan-sysview/fast_parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastparse-0.1.0rc28-py3-none-manylinux2014_x86_64.whl -
Subject digest:
6ef77b04e98599c414b234f8d5e8d35ceba3fc5fd907120033dd513cdb72625a - Sigstore transparency entry: 2026161241
- Sigstore integration time:
-
Permalink:
natan-sysview/fast_parser@d2966fd4eaeec117c034db2e697b0280f82482bf -
Branch / Tag:
refs/tags/v0.1.0-preview.28 - Owner: https://github.com/natan-sysview
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d2966fd4eaeec117c034db2e697b0280f82482bf -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastparse-0.1.0rc28-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastparse-0.1.0rc28-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 172.8 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25d055d600f0dbbd460f881021c948146cd3711d1ed92f4889ce4d67aa5f387c
|
|
| MD5 |
82d2794f82fdad743ee6d25cad31c770
|
|
| BLAKE2b-256 |
46e8c9e8ba7a0208a8ef7adce6b55dfdaef84babbae164550589c401355c9c28
|
Provenance
The following attestation bundles were made for fastparse-0.1.0rc28-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on natan-sysview/fast_parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastparse-0.1.0rc28-py3-none-macosx_11_0_arm64.whl -
Subject digest:
25d055d600f0dbbd460f881021c948146cd3711d1ed92f4889ce4d67aa5f387c - Sigstore transparency entry: 2026161154
- Sigstore integration time:
-
Permalink:
natan-sysview/fast_parser@d2966fd4eaeec117c034db2e697b0280f82482bf -
Branch / Tag:
refs/tags/v0.1.0-preview.28 - Owner: https://github.com/natan-sysview
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d2966fd4eaeec117c034db2e697b0280f82482bf -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastparse-0.1.0rc28-py3-none-macosx_10_15_x86_64.whl.
File metadata
- Download URL: fastparse-0.1.0rc28-py3-none-macosx_10_15_x86_64.whl
- Upload date:
- Size: 178.2 kB
- Tags: Python 3, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebf103e15b7ac47e7457401a0c9148800d8437e223b0cb534fc922476851dcca
|
|
| MD5 |
f2744602ec83bada716606a87a6f1267
|
|
| BLAKE2b-256 |
6b08bcd5f2f71fbbf34af9e2f071f8761880a23e4e65c9352ddace86a141b587
|
Provenance
The following attestation bundles were made for fastparse-0.1.0rc28-py3-none-macosx_10_15_x86_64.whl:
Publisher:
release.yml on natan-sysview/fast_parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastparse-0.1.0rc28-py3-none-macosx_10_15_x86_64.whl -
Subject digest:
ebf103e15b7ac47e7457401a0c9148800d8437e223b0cb534fc922476851dcca - Sigstore transparency entry: 2026160938
- Sigstore integration time:
-
Permalink:
natan-sysview/fast_parser@d2966fd4eaeec117c034db2e697b0280f82482bf -
Branch / Tag:
refs/tags/v0.1.0-preview.28 - Owner: https://github.com/natan-sysview
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d2966fd4eaeec117c034db2e697b0280f82482bf -
Trigger Event:
push
-
Statement type: