Skip to content

How to cache classmethods/staticmethods? #17

Answered by awolverp
rdong8 asked this question in Q&A
Discussion options

You must be logged in to vote

Use cached for staticmethod and cachedmethod for classmethod.

    @cachedmethod(...)
    @classmethod
    def test1(cls, params):
        ...

    @cached(...)
    @staticmethod
    def test2(params):
        ...

Editor might show an error (if type checking is enabled) or might not correctly infer the return value (in this case, just specify what the function will return), but the code works. I'll fix this issue soon.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@rdong8
Comment options

@awolverp
Comment options

@rdong8
Comment options

@awolverp
Comment options

Answer selected by rdong8
Comment options

You must be logged in to vote
1 reply
@awolverp
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants