Skip to main content

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.
  • Python copies the returned native buffer and frees the native result.

Install

From PyPI, once the package is published:

pip install fastparse

From a downloaded wheel:

pip install fastparse-0.1.0rc14-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

parser = FastParse()
source = b"class Demo { void run() {} }"

result = parser.parse_bytes(
    source,
    language="java",
    output_format="json",
    fields=["rule", "text", "byte_range"],
)

print(result.node_count)
print(result.json())

Binary MessagePack output:

result = tsmp.parse_bytes(
    source,
    language="java",
    output_format="binary",
    fields=["rule", "text", "byte_range"],
)

print(result.node_count)
print(result.data)  # MessagePack bytes

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fastparse-0.1.0rc14-py3-none-win_amd64.whl (107.5 kB view details)

Uploaded Python 3Windows x86-64

fastparse-0.1.0rc14-py3-none-manylinux2014_x86_64.whl (181.1 kB view details)

Uploaded Python 3

fastparse-0.1.0rc14-py3-none-macosx_11_0_arm64.whl (163.2 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

fastparse-0.1.0rc14-py3-none-macosx_10_15_x86_64.whl (168.5 kB view details)

Uploaded Python 3macOS 10.15+ x86-64

File details

Details for the file fastparse-0.1.0rc14-py3-none-win_amd64.whl.

File metadata

  • Download URL: fastparse-0.1.0rc14-py3-none-win_amd64.whl
  • Upload date:
  • Size: 107.5 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastparse-0.1.0rc14-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 603a440845d45fddf356f27b9267335cd0f0de22fab28fc77976c2c9128f45ae
MD5 7a45ef2488d684c78dfa4b45c1eedd75
BLAKE2b-256 9916c4fe734b8867dd8ababa62fc69dbad129aea388070646c9db854b9174da3

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastparse-0.1.0rc14-py3-none-win_amd64.whl:

Publisher: release.yml on natan-sysview/fast_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastparse-0.1.0rc14-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastparse-0.1.0rc14-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b548583857bd95b8c2128d91a5366cfef790294b466a33e92998fe64215b5d1b
MD5 c1b7a670d4a054d70900c75823b2a4d4
BLAKE2b-256 f5bdf382b5afea61e4edaa1bd178a353994d34043e763e32749fe744ecd0ace5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastparse-0.1.0rc14-py3-none-manylinux2014_x86_64.whl:

Publisher: release.yml on natan-sysview/fast_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastparse-0.1.0rc14-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastparse-0.1.0rc14-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20e4e14b7bb97d06b890a8f62a45fd8fb81585650a8c86638bfc226df6a05572
MD5 96551960997da7e4bcc11d87dd143b14
BLAKE2b-256 ed4e2bdec19b9ac416a39d3138a7ff5d5115e32d626053501f237c88c4e0d497

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastparse-0.1.0rc14-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on natan-sysview/fast_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastparse-0.1.0rc14-py3-none-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for fastparse-0.1.0rc14-py3-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 85b5af3b2bf8a6038ed9e4d526ab57981ee86632ea567ddfaf312175f28a5b58
MD5 f5ca4f561f8ebd5ad66d00449ec055ab
BLAKE2b-256 ec6ee3e9dd14fc0c9d6411ef705372c58340a4d32c1093f1483c4422b04f213c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastparse-0.1.0rc14-py3-none-macosx_10_15_x86_64.whl:

Publisher: release.yml on natan-sysview/fast_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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