Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cached_method: __name__ and __module__ attributes; callable as functions / class bound methods #15759

Closed
nthiery opened this issue Jan 29, 2014 · 12 comments

Comments

@nthiery
Copy link
Contributor

nthiery commented Jan 29, 2014

This ticket adds the following features to cached methods to make them
behave more like usual methods:

  • __name__ and __module__ attributes

  • calling them as functions / methods bound on a class:

    class Foo:
        @cached_method
        def f(self):
            ...
    
    sage: instance = Foo()
    sage: Foo.f(instance) is instance.f()
    sage: Foo.__dict__['f'](instance) is instance(f)
    

This makes them compatible with, e.g., deprecated_function_alias:

class Foo:
    @cached_method
    def f(self):
        ...
    bar = deprecated_function_alias(12963, f)

CC: @simon-king-jena

Component: misc

Author: Nicolas M. Thiéry

Branch: 6b18661

Reviewer: Simon King

Issue created by migration from https://trac.sagemath.org/ticket/15759

@nthiery nthiery added this to the sage-6.1 milestone Jan 29, 2014
@nthiery
Copy link
Contributor Author

nthiery commented Jan 29, 2014

Branch: public/ticket/15759

@nthiery
Copy link
Contributor Author

nthiery commented Jan 29, 2014

Commit: 6b18661

@nthiery
Copy link
Contributor Author

nthiery commented Jan 29, 2014

Reviewer: Simon King?

@nthiery
Copy link
Contributor Author

nthiery commented Jan 29, 2014

New commits:

6b18661Implementation of 15759

@nthiery
Copy link
Contributor Author

nthiery commented Jan 29, 2014

Author: Nicolas M. Thiéry

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@simon-king-jena
Copy link
Member

comment:4

The code looks good, all tests pass, and in fact in the past I have considered to add the __name__ attribute myself. Positive review.

@simon-king-jena
Copy link
Member

Changed reviewer from Simon King? to Simon King

@nthiery
Copy link
Contributor Author

nthiery commented Feb 25, 2014

comment:5

Thanks Simon for the review!

@vbraun
Copy link
Member

vbraun commented Mar 2, 2014

Changed branch from public/ticket/15759 to 6b18661

@robertwb
Copy link
Contributor

robertwb commented Mar 5, 2014

comment:7

Remove tabs from description.

@robertwb

This comment has been minimized.

@robertwb
Copy link
Contributor

robertwb commented Mar 5, 2014

Changed commit from 6b18661 to none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants