Skip to content

Add similar improvements for rp2.asm_pio #787

Open
@Josverl

Description

@Josverl

def asm_pio(_func: Callable[_Param, _Ret], /) -> Callable[_Param, _Ret]:

but also consider that decoraters can also be implemented as a class ,
and that may be the missing link beween def asm_pio and class asm_pio

https://realpython.com/primer-on-python-decorators/#using-classes-as-decorators

class asm_pio:
    def __init__(self, func):
        functools.update_wrapper(self, func)
        self.func = func
        self.num_calls = 0

    def __call__(self, *args, **kwargs):
        self.num_calls += 1
        print(f"Call {self.num_calls} of {self.func.__name__}()")
        return self.func(*args, **kwargs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions