Welcome to PyGX¶
PyGX is a toolkit for advanced Python programming, built on symbolic object-oriented programming (SOOP) — a programming model that treats Python programs as first-class, mutable data. It enables expressive patterns for inspecting, transforming, generating, and searching over code and objects, and has been used both for complex machine learning scenarios (such as AutoML) and for facilitating everyday programming tasks with extra flexibility.
PyGX is a continuation and evolution of the PyGlove project from Google, now developed independently.
Where to go next¶
- User Guide — practical, task-oriented walkthroughs for Python, ML, AutoML, and evolution use cases.
- Learning PyGX — conceptual material on Symbolic Object-Oriented Programming and Symbolic Detour.
- API Reference — generated from the source.
Install¶
Hello, PyGX¶
import pygx as pg
class Greeter(pg.Object, sym=True):
name: str
greeting: str = "Hello"
def say(self) -> str:
return f"{self.greeting}, {self.name}!"
g = Greeter(name="world")
print(g.say()) # Hello, world!
# Symbolic objects (`sym=True`) can be inspected and mutated in place.
# (Without it, a `pg.Object` subclass is a flat validated dataclass.)
g.sym_rebind(greeting="Bonjour")
print(g.say()) # Bonjour, world!