NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #990 most downloaded on PyPI
Small library to dynamically create python functions.
Last release 1 years ago
09 May 2025
Ships fairly regularly
a new release about every 6 months
Nearly every release is documented
notes for 53 of 54 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
54 releases · first in 2019
Removed official support for python versions <3.9 . These versions will not run in CI anymore.
<3.9. These versions will not run in CI anymore.RuntimeError in tests when running on python 3.14. Added python 3.14 to CI. FixesSee documentation page for details.
Fixed issue with legacy python 2.7 and 3.5. Fixes #110
See documentation page for details.
One column per quarter.
Python 3.13 is now supported. PR #108 and PR #104 by mgorny
See documentation page for details.
Fixed SyntaxError: invalid syntax happening when the default value of one argument of the created function is a subclass of a basic primitive. Fixes #
SyntaxError: invalid syntax happening when the default value of one argument of the created function is aSee documentation page for details.
Fixed SyntaxError happening when the name of a native coroutine function to create contains 'return' . Fixes #96 .
SyntaxError happening when the name of a native coroutine function to create contains 'return'.See documentation page for details.
Fixed ValueError: Invalid co_name happening on python 2 when the name of a function to create starts or ends with _ or contains a double __ . Fixes #9
ValueError: Invalid co_name happening on python 2 when the name of a function to create starts or ends with_ or contains a double __ . Fixes #91See documentation page for details.
wraps now always sets the __wrapped__ attribute, and also sets the __signature__ attribute when the signature changes, as specified by PEP 362. PR by
wraps now always sets the __wrapped__ attribute, and also sets the __signature__ attribute when the signature changes, as specified by PEP 362. PR by #86 by lucaswiman.See documentation page for details.
create_wrapper , create_function , wraps and with_signature now support lambda functions. They also accept a new parameter co_name to define the name
create_wrapper, create_function, wraps and with_signature now support lambda functions. They also accept a new parameter co_name to define the name to be used in the compiled code. PR #80 by andrewcleveland.See documentation page for details.
Fixed an issue where using partial on a generator function in python 3.5 was raising a SyntaxError . Fixed #79
partial on a generator function in python 3.5 was raising a SyntaxError. Fixed #79See documentation page for details.
async generator functions are now supported (See PEP525 ). Fixed #77 . PR#78 by broglep-work .
Fixed TypeError when a func attribute is present on the function provided to create_function . Fixed #76
when no argument is provided, it is equivalent to wraps(f)(f) . That is, the __wrapped__ attribute is set. Fixed #73
Fixed partial so that :
when no argument is provided, it is equivalent to wraps(f)(f) . That is, the wrapped attribute is set. Fixed #73
it sets the func attribute just as functools.partial does. Fixed #75
Removed pytest-cases dependency as it was a circular one. Fixed #68
Now using flake8 for qualimetry and genbadge for badges. Fixed #71
Restructured project so that tests are truly independent, to ease rpm/apt/etc. packaging. Fixed #69
When a default value v in a signature is representable but its eval(repr(v)) raises an exception, created signatures would raise an exception instead
Fixed issue where @wraps does not remove the __wrapped__ attribute when it wraps an already-wrapped function, and modifies its signature. Fixes #66
Fixed a bug happening when trying to generate a function where float('inf') is used as a default value. Fixes #63 .
- @wraps now has new arguments prepend_arg and append_arg to quickly prepend or append a new parameter to a function signature. Fixes #65
@wraps now has new arguments prepend_arg and append_arg to quickly prepend or append a new parameter to a function signature. Fixes #65
add_signature_parameters can now receive string parameter names in its first and last arguments.
Improved generated docstring for partial with better support for preset positional args.
partial 's behaviour is now aligned with the one in functools.partial in terms of arguments order and kind. Fixes #64
Bug fix: passing preset positional arguments to partial does not wipe out the rest of the signature any more. Fixes #62
Technical release: validation of the new github actions workflow.
Technical release: validation of the new github actions workflow for PyPi deployment.
@wraps now offers a remove_params argument allowing one to remove an argument from the exposed signature, typically to create and inject it in the wra
partial can now be used to create a copy of a function with no args. Fixed ValueError: Cannot preset 0 positional args, function case_second has only
Removed unused six dependency. Note: this version will ship in conda forge.
- @wraps can now be used to wrap a functools.partial . Fixed #57
@wraps can now be used to wrap a functools.partial . Fixed #57
create_function now correctly reuses information from the partialized function if a functools.partial is used as the implementation.
create_function now raises a more explicit error when no func_name can be found.
makefun.partial now generates a signature that is more consistent with functools.partial . Fixes #58
packaging improvements: set the "universal wheel" flag to 1, and cleaned up the setup.py . In particular removed dependency to six for setup and added
Fixed OSError: could not get source code or IOError: could not get source code when @compile_fun is used on a function that depends on an already-comp
Fixed OSError: could not get source code or IOError: could not get source code when @compile_fun is used on a function that depends on an already-compiled function. Fixed #51
@compile_fun : added capability to disable recursive compilation ( recurse arg) , and to exclude some names from compilation ( except_names arg). Fixe
@compile_fun : added capability to disable recursive compilation ( recurse arg) , and to exclude some names from compilation ( except_names arg). Fixed #49 and #50
Fixed issue ValueError: Cell is empty with @compile_fun . Fixed #48
Now raising an UndefinedSymbolError when a symbol is not known at compilation time. One step towards #47
New goodie @compile_fun decorator to compile a function so that it can not be navigated to using the debugger. Fixes #46
New goodie @compile_fun decorator to compile a function so that it can not be navigated to using the debugger. Fixes #46
add_signature_parameters now accepts that one specifies a custom index where to insert the new parameters.
add_signature_parameters now accepts that one specifies a custom index where to insert the new parameters.
Added __version__ attribute to comply with PEP396, following this guide . Fixes #45 .
Added version attribute to comply with PEP396, following this guide . Fixes #45 .
Fixed six dependency: also declared as a setup dependency.
Fixed six dependency: also declared as a setup dependency.
Added missing six dependency explicitly.
Added missing six dependency explicitly.
Improved performance of inner method get_signature_string (used by all entry points) after profiling.
In python 2 some libraries such as attrs can modify the annotations manually, making signature return a string representation that is not compliant wi
Fixed yet another nasty varpositional-related bug :). Fixes #38 .
Fixed NameError in case of unknown symbols in type hints. Fixes #37 .
Fixed bug when the return type annotation of the function to create contains non-locally available type hints. Fixes #33 .
Fixed bug when the return type annotation of the function to create contains non-locally available type hints. Fixes #33 .
Fixed bug when the signature of the function to create contains non-locally available type hints. Fixes #32 .
Fixed bug when the signature of the function to create contains non-locally available type hints. Fixes #32 .
Fixed partial to support missing and empty docstring. Fixes #31 .
Fixed partial to support missing and empty docstring. Fixes #31 .
New method partial that behaves like functools.partial , and equivalent decorator @with_partial . Fixes #30 .
New method partial that behaves like functools.partial , and equivalent decorator @with_partial . Fixes #30 .
add_signature_parameters now correctly inserts parameters in the right order when they are prepended (using first= ). Fixed #29 .
add_signature_parameters now correctly inserts parameters in the right order when they are prepended (using first= ). Fixed #29 .
renamed all handler into impl for clarity. Fixes #27 .
Function creation API:
renamed all handler into impl for clarity. Fixes #27 .
renamed addsource and addhandler arguments as add_source and add_impl respectively, for consistency
signatures can not be provided as a callable anymore - that was far too confusing. If the reference signature is a callable, then use @wraps or create_wrapper , because that's probably what you want to do (= reuse not only the signature but also all metadata). Fixes #26 .
the function name is now optional in signatures provided as string.
now setting qualname attribute
default function name, qualname, doc and module name are the ones from func_impl in create_function and @with_signature , and are the ones from the wrapped function in create_wrapper and @wraps as intuitively expected. Fixes #28 .
Wrappers:
@wraps and create_wrapper now offer a new_sig argument. In that case the wrapped attribute is not set. Fixes #25 .
@wraps and create_wrapper now correctly preserve the dict and other metadata from the wrapped item. Fixes #24
When a non-representable default value was used in the signature to generate, the code failed with a SyntaxError . This case is now correctly handled,
When a non-representable default value was used in the signature to generate, the code failed with a SyntaxError . This case is now correctly handled, by storing the corresponding variable in the generated function's context. Fixes #23 .
- Now providing a @wraps , equivalent of functools.wraps ; and a create_wrapper equivalent of functools.update_wrapper . Fixes #21
Now providing a @wraps , equivalent of functools.wraps ; and a create_wrapper equivalent of functools.update_wrapper . Fixes #21
@with_signature now does not override the name when signature is provided as a function. Fixes #22
add_signature_parameters now accepts that parameters are provided as single elements (not necessarily iterables)
Updated documentation
None can be used as the desired signature of @with_signature . This indicated that the user does not want to create a new function but only wants to u
None can be used as the desired signature of @with_signature . This indicated that the user does not want to create a new function but only wants to update the metadata. Fixes #20 .
Fixed isgeneratorfunction for old python versions, see decorator#63 .
Fixed isgeneratorfunction for old python versions, see decorator#63 .
Python<3.3-specific function body is now not loaded at all if not needed.
inject_as_first_arg was missing from @with_signature , added it. Fixed #18 .
inject_as_first_arg was missing from @with_signature , added it. Fixed #18 .
Now create_function and @with_signature create the same kind of function than the handler. So if it is a generator, a generator-based coroutine, or an
Now create_function and @with_signature create the same kind of function than the handler. So if it is a generator, a generator-based coroutine, or an async coroutine, the generated function will adapt. Fixes #6 .
Now a string signature can be provided to @with_signature without problem. Fixed #17 .
Now a string signature can be provided to @with_signature without problem. Fixed #17 .
Nothing published for this version
now exposes all options of create_function . Fixed #12 .
@with_signature :
now exposes all options of create_function . Fixed #12 .
now correctly sets the module name by default. Fixes #13
now accepts None as the new func_signature to declare that the signature is identical to the decorated function. This can be handy to just change the docstring or module name of a function for example. Fixes #15
create_function and @with_signature :
New module_name parameter to override the module name. Fixes #14
the handler is now available as a field of the generated function (under func_impl ). New addhandler parameter (default: True) controls this behaviour. Fixes #16
Misc:
New goodie to manipulate signatures: add_signature_parameters .
Fixed dependencies for documentation auto-build.
New helper function remove_signature_parameters .
New helper function remove_signature_parameters .
Fixed issue with @with_signature when argument is a Signature . Fixes #11
New decorator @with_signature to change the signature of a callable. Fixes #3
New decorator @with_signature to change the signature of a callable. Fixes #3
create_function now accepts that a function be passed as a signature template. Fixes #10
Functions can now be created from a Signature object, in addition to string signatures. This unlocks many useful use cases, among easily creating func
Functions can now be created from a Signature object, in addition to string signatures. This unlocks many useful use cases, among easily creating function wrappers. Note: the inner function that provides this feature is get_signature_from_string . Fixes #8
Improved design by getting rid of the regular expression parser to check parameters definition. This assumes that the compiler will correctly raise exceptions when a string signature is not correct, and that inspect.signature or funcsigs.signature works correctly at detecting all the parameter kinds and annotations on the resulting function. It seems like a fair assumption... Fixes #9 .
- create_function does not require users to prepend "def " to the signature anymore. Fixed #5
create_function :
create_function does not require users to prepend "def " to the signature anymore. Fixed #5
Return annotations are now supported. Fixes #4 .
Type hint as comments are supported but the generated function loses the annotations because inspect.signature loses the annotation too in that case. Fixes #7
Variable-length arguments such as *args and **kwargs are now properly handled. Fixes #2
Handler functions can now receive the dynamically created function as first argument, by using create_function(func_signature, func_handler, inject_as_first_arg=True) . Fixes #1
Renamed call into func_impl in the generated code.
Misc:
First version created, largely inspired by decorator
First version created, largely inspired by decorator
Your coding agent can read these notes before it upgrades. Set up the MCP server →