Skip to main content

ASTx

ASTx is a language-agnostic Python model for abstract syntax trees. It provides typed nodes and common metadata that parsers, analyzers, transpilers, and compiler backends can share without adopting a particular source grammar.

Status: functional and actively evolving. ASTx models more constructs than any one backend necessarily supports.

Scope

ASTx currently models:

  • source locations, identifiers, expressions, statements, and blocks
  • scalar, string, temporal, collection, generic, and union types
  • functions, defaults, modules, packages, and imports
  • conditionals, loops, generators, comprehensions, and context managers
  • classes, structs, inheritance, member access, and modifiers
  • templates, FFI pointers/opaque handles, and semantic helper metadata
  • lists, buffer views, tensors, DataFrames, and Series
  • YAML, JSON, Mermaid, PNG, and optional console visualization paths

ASTx does not lex or parse source and does not generate LLVM by itself. IRx is the Arx ecosystem backend that analyzes and lowers the supported ASTx subset.

Install

pip install astx

For ASCII visualization through mermaid-ascii:

pip install 'astx[console]'

Example

import astx

args = astx.Arguments(
    astx.Argument(name="x", type_=astx.Int32()),
    astx.Argument(name="y", type_=astx.Int32()),
)

body = astx.Block()
body.append(
    astx.FunctionReturn(
        astx.BinaryOp(
            op_code="+",
            lhs=astx.Variable("x"),
            rhs=astx.Variable("y"),
        )
    )
)

add = astx.FunctionDef(
    prototype=astx.FunctionPrototype(
        name="add",
        args=args,
        return_type=astx.Int32(),
    ),
    body=body,
)

print(add.to_yaml())

Relationship to Arrow

ASTx defines the compiler-facing node and type vocabulary for arrays, buffer views, Tensors, DataFrames, and Series. It deliberately does not depend on Apache Arrow or own native storage. IRx maps those nodes to its Arrow C++ runtime.

Documentation: https://arxlang.org/astx/

License: Apache-2.0.

Metadata

Release files for astx 1.24.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 astx 1.24.1
File Size Uploaded
astx-1.24.1.tar.gz 47.9 kB Details

Built distribution (wheel)

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

Total release size: 120.2 kB

Release files / astx-1.24.1.tar.gz

Download URL astx-1.24.1.tar.gz
Size 47.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d81ee0aaca6c61438963ce00d5f86872a207cddf19ad50ce0d1d4c3667f005ee
BLAKE2b-256 checksum
How to use checksums
e116f573fa60d2d0b95614a27a623ad663929994ab3f089b1d1cbfd9facd0fce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1020-azure

Release files / astx-1.24.1-py3-none-any.whl

Download URL astx-1.24.1-py3-none-any.whl
Size 72.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f48f68159ec0bafe5863295a6936466aa23f1ee150f7297b273a0563075f9dfd
BLAKE2b-256 checksum
How to use checksums
4b45b897be1a1a18f160be5470091713f00710a472d7d5e89d03ac62de1ed9cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.10.20 Linux/6.17.0-1020-azure

Release history Release notifications | RSS feed

This release

1.24.1 This release

2 release files

1.23.1

2 release files

1.23.0

2 release files

1.22.0

2 release files

1.21.0

2 release files

1.20.0

2 release files

1.19.2

2 release files

1.19.1

2 release files

0.23.1

2 release files

0.23.0

2 release files

0.21.1

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.18.2

2 release files

0.18.1

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.13.2

2 release files

0.13.1

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 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