{"id":7158,"library":"diastatic-malt","title":"Diastatic Malt","description":"Diastatic Malt (pypi-slug: `diastatic-malt`) is a Python library (current version 2.15.3) designed for source-to-source transformations and operator overloading, including the ability to overload built-in Python keywords. It allows for transforming regular Python code into a new form suitable for specific purposes, such as program capture. The library's core functionalities are adapted from TensorFlow's AutoGraph module, aiming to provide similar capabilities without a direct TensorFlow dependency. Releases are infrequent and tied to internal needs, with minor versions released as changes are integrated.","status":"active","version":"2.15.3","language":"en","source_language":"en","source_url":"https://github.com/PennyLaneAI/diastatic-malt","tags":["operator overloading","AST transformation","AutoGraph","meta-programming","source-to-source"],"install":[{"cmd":"pip install diastatic-malt","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary import for accessing the library's functionalities. Specific classes or functions for transformation would typically be accessed as attributes of this module after import.","symbol":"diastatic_malt","correct":"import diastatic_malt"}],"quickstart":{"code":"import diastatic_malt\n\n# Diastatic Malt is a tool for source-to-source transformations and operator overloading.\n# Its primary use case is within contexts requiring Python code transformation,\n# similar to TensorFlow's AutoGraph.\n# As such, a direct, simple 'quickstart' involves understanding its application\n# for modifying Python's AST or operator behavior, rather than a standalone function call.\n# Actual usage would depend on the specific transformation or overloading task.\n# For example, to enable specific operator overloading for a function:\n\n# def my_function(x, y):\n#     return x + y\n\n# transformed_function = diastatic_malt.transform(my_function)\n# (Note: 'transform' is a hypothetical example as specific API calls are not publicly documented.)\n\nprint(\"Diastatic Malt is installed and available for code transformation tasks.\")","lang":"python","description":"Diastatic Malt's quickstart revolves around its core capability: source-to-source transformations and operator overloading. Due to its nature as a foundational tool (derived from TensorFlow's AutoGraph), a simple, universally applicable 'hello world' style code snippet is not readily available or indicative of its true usage. The typical flow involves importing the library and then applying its transformation mechanisms to user-defined Python code or functions to alter their runtime behavior or enable specific operator overloads. Users are expected to interact with its API to define and apply these transformations."},"warnings":[{"fix":"If your project implicitly or explicitly relied on `gast` being a transitive dependency of `diastatic-malt`, you will need to update your imports or direct dependencies to use Python's built-in `ast` module or explicitly include `gast` in your project's dependencies if still required for other reasons. The change aims for better compatibility and reduced dependencies.","message":"The `gast` dependency has been removed and replaced with the standard library `ast` module.","severity":"breaking","affected_versions":">=2.15.3"},{"fix":"Always qualify searches with 'python library' or refer to the PyPI/GitHub project directly to ensure you are consulting information relevant to the software package.","message":"Diastatic Malt (the Python library) is frequently confused with 'diastatic malt powder', a culinary ingredient. This can lead to misleading search results or incorrect assumptions about the library's purpose.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Replace any direct or indirect reliance on `gast` with Python's standard `ast` library. If `gast` is still required by other parts of your project, ensure it is explicitly listed in your `requirements.txt`.","cause":"Upgrading to diastatic-malt v2.15.3 or later removed the `gast` dependency.","error":"ModuleNotFoundError: No module named 'gast'"},{"fix":"Refer to the GitHub repository for the latest source code to identify available classes and functions, or consult projects that leverage `diastatic-malt` for practical usage patterns. The library's main purpose is source transformation, so direct utility functions might be less common than decorator-based or API-driven transformations.","cause":"The public API for `diastatic-malt` is not extensively documented with typical examples. Many functionalities are likely internal or mirror specific AutoGraph patterns, making expected attribute names non-obvious without deeper understanding of its source or specific use cases.","error":"AttributeError: module 'diastatic_malt' has no attribute 'some_expected_function'"}]}