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
Refactor getattr_from_other_class() for lookup of methods in categories #20686
Comments
comment:2
I might have some ideas... discuss in Meudon? |
comment:3
+1 |
This comment has been minimized.
This comment has been minimized.
Author: Jeroen Demeyer |
Dependencies: #20825 |
Commit: |
Upstream: Reported upstream. No feedback yet. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Changed upstream from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release. |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:72
And also not related to
|
comment:73
The last patchbot report was green, so this must be a recently-introduced problem. |
comment:74
Interestingly, these failures are for classes inheriting from |
comment:75
Those failures are true bugs in
and
I think the right thing to do here is to mark those tests as |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:78
I hope to fix both today. |
comment:79
good to go! |
comment:80
This ticket seems to cause #21409 |
Changed branch from u/jdemeyer/optimize_method_lookup_from_the_categories_for_instances_of_cython_classes to |
For parents and elements implemented in Cython, category lookup is emulated in
__getattr__
usinggetattr_from_other_class
. In this ticket, this is refactored a bit:type
, there is no point in returning the type name of the category here (similarly for__dict__
,__mro__
, ...):This change causes a few failures which need to be fixed.
The implementation of
getattr_from_other_class
is not very robust. For example, static methods are not supported. We fix this by using low-level Python functions to get the attribute and we manually call the descriptor__get__
if needed.We shouldn't do anything special with double-underscore private attributes: in plain Python, this is implemented by the parser and not by
getattr()
. So__getattr__
would already receive the mangled private name.Some of the changes broke
_sage_src_lines_
, so we also change that: currently,_sage_src_lines_()
is used both to get the source lines of a class (e.g. dynamic classes) and an instance (e.g. cached functions). We change this to always mean the source lines of an instance, which makes things clearer.The lookup using
getattr_from_other_class
is about 9 times slower than a normal method lookup::We improve on this by roughly a factor 2 (but even then, it's still a lot slower than usual method lookup).
NOTE: This needs a trivial Cython patch, see #21030 for the Cython upgrade.
Depends on #21030
Depends on #21409
Upstream: Fixed upstream, in a later stable release.
CC: @jdemeyer @tscrim
Component: categories
Author: Jeroen Demeyer
Branch/Commit:
74041f3
Reviewer: Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/20686
The text was updated successfully, but these errors were encountered: