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.0rc13-py3-none-macosx_11_0_arm64.whl

The wheel includes the native library for its platform, 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.0rc13-py3-none-win_amd64.whl (107.0 kB view details)

Uploaded Python 3Windows x86-64

fastparse-0.1.0rc13-py3-none-manylinux2014_x86_64.whl (180.6 kB view details)

Uploaded Python 3

fastparse-0.1.0rc13-py3-none-macosx_11_0_arm64.whl (162.7 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

fastparse-0.1.0rc13-py3-none-macosx_10_15_x86_64.whl (168.1 kB view details)

Uploaded Python 3macOS 10.15+ x86-64

File details

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

File metadata

  • Download URL: fastparse-0.1.0rc13-py3-none-win_amd64.whl
  • Upload date:
  • Size: 107.0 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.0rc13-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 98b6719c6a673a4ad4638ffb14d16da5d5021c4d11b10dbea6e56ff57f79334c
MD5 84da6cd95e3d1f6918683a273e88caef
BLAKE2b-256 27b1e13a0e3f5a34a89833edf6caebe4ee1b672f8fabb1d1177d47848c0180bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastparse-0.1.0rc13-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.0rc13-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastparse-0.1.0rc13-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c79371e6a18b378b302fc6479ca85454687b0a8d17ee633f67f9f50418161cb1
MD5 408a06ee38fcce3f58030ce9477bd14a
BLAKE2b-256 7d5547aa991a7f0cc091bf06401acc49b07893062aa0a4d3221c9c85537b4ac4

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastparse-0.1.0rc13-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.0rc13-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastparse-0.1.0rc13-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a9c5a02f68b50b411dfaf6d1fbe00c174fcfa3883c60668e799c5a577a5b0dc
MD5 9192a703f7bb39247ae37a449b690070
BLAKE2b-256 326ba52b1e877a516c43f1566fa404826635492f1d01d22ac7a407f0f03f3545

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastparse-0.1.0rc13-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.0rc13-py3-none-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for fastparse-0.1.0rc13-py3-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 38b33b220c9b8f1c0dc3b306db6962bff8a7f44991bf1c7eadbc138b26604913
MD5 bb7af6ee43c571bdbbd403e4cfaaa41b
BLAKE2b-256 6915281c172d78fe1f57ea41c0fc601b902b2680fc3ca7a557e07028676d38a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastparse-0.1.0rc13-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