Skip to content Skip to sidebar Skip to footer

Python Cprofile - Decorated Functions Obscuring Profile Visualization

I have a base class with a @classmethod which acts as a decorator for a large number of methods in many descendant classes. class BaseClass(): @classmethod def some_decorat

Solution 1:

There are ways to build decorators to preserve docs/signatures. The wrapt library provides a lot of functionality to that end.

https://wrapt.readthedocs.io/en/latest/decorators.html#decorating-class-methods

It would end up looking something like this:

classBaseClass():
    @wrapt.decorator    @classmethoddefsome_decorator(cls, method, instance, *args, *kwargs):
        # do stuffreturn method(instance, *args, **kwargs)

Post a Comment for "Python Cprofile - Decorated Functions Obscuring Profile Visualization"