-
-
Notifications
You must be signed in to change notification settings - Fork 581
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
Support cached_methods on extension types #12951
Comments
comment:1
As it turns out, it is still impossible to use arbitrary decorators on c(p)def functions or methods. However, the attached patch makes it possible to use the decorator on def-methods of extension classes. That used to fail, because of the attribute error mentioned in the ticket description. It is of course still required that the instances of the extension class either allow to override an attribute of the class by an attribute of the instance, or that the instance has a public attribute For the latter case, we now have (from the doc tests):
Note that by #11115, sage.structure.parent.Parent has the Providing attribute access is a bit more tricky, since it is needed that an attribute inherited by the instance from its class can be overridden on the instance. That is why providing a
Supporting attribute access apparently is more complicated than the other approach, and probably not recommended. However, on cached methods, it is somehow faster than the easier method:
Needs review! |
Author: Simon King |
comment:2
Any reviewer? |
Dependencies: #12215 |
comment:4
Note to myself: Test that this patch still applies. |
Patch relative to #12215 |
comment:5
Attachment: trac12951_cached_extension.patch.gz I had to rebase the patch. Now it should work again. Still needing review! |
Reviewer: Travis Scrimshaw |
comment:7
Looks good to me. Thanks Simon. |
Merged: sage-5.9.beta4 |
In old versions of Cython, one would have seen an error like "arbitrary decorators are not supported" when attempting to use
@
cached_method on the methods of a cdef class. That has now been improved. However, cached methods would still not work, because an attribute__module__
is requested that does not exist.The aim is to work around that limitation, so that cached methods and functions genuinely work in Cython.
Depends on #12215
CC: @hivert @robertwb
Component: misc
Author: Simon King
Reviewer: Travis Scrimshaw
Merged: sage-5.9.beta4
Issue created by migration from https://trac.sagemath.org/ticket/12951
The text was updated successfully, but these errors were encountered: