I mistakenly sent this reply directly to TB instead of the list:
On 2025-10-07 4:54 p.m., TB wrote:
When handling inheritance, there is a disadvantage to defining an alias
with `bar = foo`.
The advantage of course is less function call overhead than the alternative.
instead of the better solution
of having the full docstring of foo() with a prefix that tells this is
an alias.
I think this could principle be handled automatically by Sphinx when
using bar = foo (this is https://github.com/sagemath/sage/issues/40759).
sage: class B(A):
....: def foo(self):
....: return 42
....:
sage: b = B()
sage: b.foo()
42
sage: b.bar() # surprise?
5
sage: b.__getattribute__("bar").__name__
'foo'
sage: b.__getattribute__("foo").__name__
'foo'
That's an interesting test case! But I think using __qualname__ instead
of __name__ allows these kinds of situations to be handled. I'm curious
if there is anywhere where this happens in Sage, if so that could be a
bug. I'm also wondering if this situation could be detected by linters.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/sage-devel/6da223e5-b504-4557-a0f7-0d81b05e5207%40ucalgary.ca.