{"library":"makefun","code":"from makefun import create_function, wraps\nfrom inspect import Signature, Parameter\n\n# Example 1: Creating a function from scratch\ndef my_implementation(a, b):\n    return f\"a={a}, b={b}\"\n\nsig = Signature([\n    Parameter('a', Parameter.POSITIONAL_OR_KEYWORD),\n    Parameter('b', Parameter.POSITIONAL_OR_KEYWORD, default=2)\n])\n\ndynamic_func = create_function(sig, my_implementation, doc=\"A dynamically created function\")\nprint(dynamic_func(1)) # Output: a=1, b=2\nprint(dynamic_func(10, b=20)) # Output: a=10, b=20\n\n# Example 2: Wrapping an existing function and changing its signature\ndef original(x, y):\n    return x * y\n\n@wraps(original, new_sig=Signature([Parameter('val', Parameter.POSITIONAL_OR_KEYWORD)]))\ndef my_wrapper(val):\n    # original expects x, y. Let's map 'val' to both.\n    return original(val, val)\n\nprint(my_wrapper(val=5)) # Output: 25","lang":"python","description":"This quickstart demonstrates the core functionalities: creating a new function with `create_function` by specifying its signature and implementation, and wrapping an existing function while modifying its signature using the `wraps` decorator.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}