{"id":4534,"library":"fiddle","title":"Fiddle: A Python-first configuration library","description":"Fiddle is a Python-first configuration library designed particularly for machine learning applications. It enables deep configurability of parameters in a program, allowing configurations to be expressed in readable and maintainable Python code. It aims to reduce boilerplate and provides good error messages. The library is currently at version 0.3.0 and is actively developed by Google.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/google/fiddle","tags":["configuration","machine learning","dependency injection","config-management"],"install":[{"cmd":"pip install fiddle","lang":"bash","label":"Basic Installation"},{"cmd":"pip install fiddle[flags]","lang":"bash","label":"With CLI Flag Support (absl-py)"}],"dependencies":[{"reason":"Provides command-line flag support when installed with the 'flags' extra.","package":"absl-py","optional":true}],"imports":[{"note":"The official documentation and examples consistently use the `fdl` alias for `fiddle`.","symbol":"fiddle","correct":"import fiddle as fdl"},{"symbol":"Config","correct":"from fiddle import Config"}],"quickstart":{"code":"import fiddle as fdl\n\ndef create_greeting(prefix: str, name: str = \"World\", punctuation: str = \"!\"):\n    return f\"{prefix} {name}{punctuation}\"\n\n# Create a Fiddle configuration for the function\ncfg = fdl.Config(create_greeting, prefix=\"Hello\", name=\"Fiddle\")\n\n# Build the configured function to get the result\nresult = fdl.build(cfg)\nprint(f\"Original Fiddle build: {result}\")\n\n# Modify the configuration\ncfg.punctuation = \"!!\"\nresult_modified = fdl.build(cfg)\nprint(f\"Modified Fiddle build: {result_modified}\")\n\n# Demonstrate fdl.Partial, which returns a functools.partial object\npartial_cfg = fdl.Partial(create_greeting, prefix=\"Hi\")\npartial_func = fdl.build(partial_cfg) # This returns a functools.partial object\nresult_partial = partial_func(name=\"Python\") # Call the partial function\nprint(f\"Partial Fiddle build: {result_partial}\")","lang":"python","description":"This quickstart demonstrates how to define configurations for Python callables using `fdl.Config` and `fdl.Partial`, and then build them using `fdl.build()`. `fdl.Config` directly builds the callable with the specified arguments, while `fdl.Partial` returns a `functools.partial` object that can be called later."},"warnings":[{"fix":"Be prepared for API adjustments and refer to release notes when upgrading. Consider pinning minor versions in production environments.","message":"Fiddle is currently in 'Development Status :: 3 - Alpha'. This means the API is not yet stable, and breaking changes may occur in future releases.","severity":"breaking","affected_versions":"0.x.x (especially pre-1.0.0)"},{"fix":"Always use `None` as a default argument, and then initialize the mutable object inside the function if `None` is passed. Example: `def func(arg=None): arg = arg or []`.","message":"Using mutable default arguments (e.g., lists, dictionaries) in functions configured by Fiddle can lead to unexpected shared state across different configurations or calls. Python evaluates default arguments once when the function is defined.","severity":"gotcha","affected_versions":"All Python versions, relevant for Fiddle configurations"},{"fix":"Understand the distinction: use `fdl.Config` when you want the immediate result of the callable's execution, and `fdl.Partial` when you want a configurable, pre-filled callable that can be invoked later with additional arguments.","message":"`fdl.Config` and `fdl.Partial` behave differently when `fdl.build()` is called. `fdl.Config` directly invokes the callable and returns its result, while `fdl.Partial` returns a `functools.partial` object that needs to be called separately to get the final result.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}