gast
Python AST that abstracts the underlying Python version
Decision gist · record as of 2026-08-14
Yes. GAST is a low-friction, actively maintained utility with no dependencies, a permissive license, and zero known vulnerabilities. Install it if you're building tools that parse or analyze Python code across multiple versions and need to avoid version-specific AST branching logic.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Installation is straightforward with no runtime dependencies.
- The package is actively maintained with a recent release and steady commit activity, making it reliable for production use.
License · maintenance · safety
BSD 3-Clause (permissive) — Licensed under BSD 3-Clause, a permissive license that allows free use, modification, and distribution with minimal restrictions, suitable for both open-source and commercial projects.
last release 2025-11-29 (258 days) · last repo commit 2026-06-24 · 147 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 20,135,601 downloads/mo, #1,044 on PyPI
Alternatives
Verify before relying
import ast
import gast
code = "x = 1 + 2"
tree = ast.parse(code)
gtree = gast.ast_to_gast(tree)
# Process gtree with version-independent AST
original_tree = gast.gast_to_ast(gtree)- Whether the package is actively used by major tools or frameworks that depend on cross-version AST compatibility
- Performance characteristics when converting large or deeply nested ASTs
What it is and what it does
GAST is a compatibility layer that normalizes Python's Abstract Syntax Tree across different Python versions. It converts version-specific AST output from the standard ast module into a unified representation, then back again if needed. This solves the problem of AST structure differences between Python 2.7 and Python 3.x versions—for instance, how function arguments, exception handlers, and string literals are represented differently across versions.
The package provides the same API as the standard ast module, with three key additions: gast.parse() produces a normalized tree directly, gast.dump() shows the unified representation, and gast.ast_to_gast() / gast.gast_to_ast() handle bidirectional conversion. It's tested across Python 2.7 through 3.11, making it suitable for tools that need to analyze or transform code written for multiple Python versions without rewriting logic for each version's AST quirks.
Use it for
- Building code analysis or refactoring tools that must work with codebases targeting multiple Python versions
- Writing AST-based linters or formatters that need a single code path for Python 2 and 3 syntax
- Implementing code generation or transpilation that normalizes input AST before processing
- Analyzing legacy Python 2 code alongside modern Python 3 code in a unified framework
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
GAST is a low-friction, actively maintained utility with no dependencies, a permissive license, and zero known vulnerabilities. Install it if you're building tools that parse or analyze Python code across multiple versions and need to avoid version-specific AST branching logic.
Install
gast on PyPI
Before you install
Installation is straightforward with no runtime dependencies. The package is actively maintained with a recent release and steady commit activity, making it reliable for production use.
License in practice
Licensed under BSD 3-Clause, a permissive license that allows free use, modification, and distribution with minimal restrictions, suitable for both open-source and commercial projects.
Quickstart
import ast
import gast
code = "x = 1 + 2"
tree = ast.parse(code)
gtree = gast.ast_to_gast(tree)
# Process gtree with version-independent AST
original_tree = gast.gast_to_ast(gtree)
Verify before relying
- Whether the package is actively used by major tools or frameworks that depend on cross-version AST compatibility
- Performance characteristics when converting large or deeply nested ASTs
Package facts
| License | BSD 3-Clause permissive |
| Python support | Supports the current Python release !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 258 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 20,135,601 / month, #1,044 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: gast-0.7.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “python ast compatibility layer”
- gastProvides a unified Abstract Syntax Tree representation that works…
- astatineAstatine provides helper functions and utilities for working with…
- qualnameProvides a `qualname()` function that emulates Python 3.3+'s…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also astpretty · beniget · parso · asttokens · ast-comments · astunparse · ast-decompiler · astor · luaparser · PyMeta3