Decorators

The decorators module provides utility decorators used internally by ecosound. listinput() ensures that a function always receives its first argument as a list, making it easy to write functions that accept both a single item and a list of items without duplicating logic. timeit() wraps any function to print its wall-clock execution time, which is useful for profiling and debugging.

Created on Thu Jan 30 11:30:08 2020

@author: xavier.mouy

ecosound.core.decorators.listinput(func)[source]

Decorator that wraps a single non-list argument in a list.

Ensures that the first positional argument passed to the decorated function is always a list. If it is not already a list, it is wrapped in one before the function is called. Useful for functions that must accept both a single item and a list of items.

ecosound.core.decorators.timeit(func)[source]

Decorator that prints the execution time of the decorated function.

Measures elapsed wall-clock time from just before the function is called to just after it returns, then prints the result to the console in seconds.