Core Concepts
This paper introduces Python bindings for the experimental egg-smol library, which aims to bring the benefits of e-graphs to the Python ecosystem. The bindings offer a high-level, Pythonic API providing an accessible and familiar interface for Python users, enabling collaboration and innovation across various domains in the scientific computing and machine learning communities.
Abstract
The paper presents Python bindings for the egg-smol library, a Rust-based e-graph implementation. The bindings expose a high-level, Pythonic API that mirrors the s-expression-based API of the original library, utilizing native Python constructs such as functions, classes, and methods.
The key highlights and insights include:
Advantages for Python Users:
The Pythonic API makes the library more accessible and easy to use for Python developers.
The bindings leverage the speed and performance of the underlying Rust library.
The bindings provide a more opinionated and consistent interface compared to other e-graph Python libraries, enabling better integration and reuse across different Python libraries.
Comparison for Existing egg-smol Users:
The Python interface may be more verbose in some aspects, such as declaring variables or adding rewrites.
However, Python's operator overloading allows for more succinct mathematical expressions.
The Python interface provides static type checking and auto-completion, which can aid in code correctness and developer productivity.
Future Work:
Supporting the embedding of existing Python types in the e-graph.
Simplifying the API for better user exposure.
Prototyping the integration with an upstream Python library.
Enabling the export and import of e-graph descriptions between Python and the s-expression language.
Leveraging Python's state management and module system for better encapsulation.
Developing interactive visualizations in Jupyter notebooks to aid in understanding e-graph execution.
The paper concludes by highlighting the potential for the egg-smol Python bindings to open up e-graphs to a wider audience within the Python ecosystem, fostering greater adoption and enabling collaboration across various domains.