Skip to main content

AST Transforms

A collection of Python AST-based code analysis and transformations.

Installation

pip install astpass

Usage

import ast
import numpy as np
from astpass.passes import shape_analysis

# Setup inputs
tree = ast.parse("a + 1")
runtime_vals = {"a": np.random.randn(3, 4)}

# Run static shape analysis
shape_info = shape_analysis.analyze(tree, runtime_vals)

# Print analysis results
for node, shape in shape_info.items():
    print(ast.unparse(node), shape)

##### Should print #####
# a (3, 4)
# 1 ()
# a + 1 (3, 4)

Passes

  • shape_analysis – returns a dictionary where each node is mapped to a shape.
  • vector_op_to_loop - transforms 1D array expressions into explicit loops.
  • To add more ...

Metadata

Release files for astpass 0.1.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 astpass 0.1.1
File Size Uploaded
astpass-0.1.1.tar.gz 16.2 kB Details

Built distribution (wheel)

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

Total release size: 35.2 kB

Release files / astpass-0.1.1.tar.gz

Download URL astpass-0.1.1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4eb727e8f5278526f2ff217cd2570eb78fbc346d46388f7425b309f826117121
BLAKE2b-256 checksum
How to use checksums
a426eba1864d96c090bd60328d142c576020fb8e41d88d193a9676d5139dbce3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / astpass-0.1.1-py3-none-any.whl

Download URL astpass-0.1.1-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6ae8f104d51f50ba80b2dfd16cf1ff627bc7a61a69ab3120caac5ddad20e9cf
BLAKE2b-256 checksum
How to use checksums
5cd3d9a92dec11cf4c00464869a15f3706bc19b502ce9e11124a5bb554d517a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.1.1 This release

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