-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Simplify the logic handling the EvaluationMethods mixin class for Expression #20859
Comments
New commits:
|
Commit: |
comment:3
You really should use new-style classes. Old-style classes exist only for backwards compatibility and will be gone in Python 3. |
comment:5
The use of |
comment:6
Thanks for creating the ticket and splitting of the commit! I am fine with this depending on #20686. |
comment:7
Replying to @jdemeyer:
Fun: from the same premises, we arrive at opposite conclusions :-) Here is my logical chain: In Python 3 we won't make the inheritance from object explicit: it would be
Furthermore, for our XXXMethods classes, it does not matter whether |
comment:8
Replying to @jdemeyer:
That's on purpose, for consistency with what we do in categories: the |
comment:9
Replying to @nthiery:
Given that it's a
How is a random Sage developer supposed to know that? That's one thing that I really don't like about the category framework in general: it makes several assumptions which work fine most of the time, but can bite you badly (the automatic binding is another such one). It almost feels like a slightly different programming language (that |
comment:10
Replying to @nthiery:
It might matter in more places than you think. There will be some porting effort needed to transition from old-style classes to new-style classes (some issues came up in #20686). It would be better to do this now to avoid unexpected issues with Python 3. For this reason, I am very against this change: - class EvaluationMethods(object):
+ class EvaluationMethods: |
comment:11
Replying to @jdemeyer:
I already did tests with inheriting from object in some XXXMethods, Furthermore, the more consistent things will be across the library, Cheers, |
comment:12
Replying to @nthiery:
So you did some limited testing now and it worked. That's a good thing, but it doesn't guarantee that it will work in all cases now and in the future. As a general principle, we should try to move Sage as close to Python 3 as possible. Python 3 has only new-style classes, so we should use new-style classes.
True, but besides the point. And of course, this just means that we should use new-style classes everywhere in Sage. |
comment:13
Replying to @jdemeyer:
Using a metaclass would mean one more piece of purely technical
That's the problem with every framework: a Django programmer needs to Now does Sage really need such a framework? I am convinced enough I also believe in concise syntax with minimal boilerplate. Of course Cheers, |
comment:14
Replying to @jdemeyer:
Everywhere, unless we have a good reason to be convinced this does not make a difference. Would we really gain something worth the trouble by adding an explicit inheritance from object in all 292 XXXMethods classes in Sage, and then removing them after the switch to Python3, with all the risks of induced syntactical conflicts, when we know that they are treated uniformly? There are real issues in the switch to Python 3, and I believe this is not one. Cheers, |
comment:15
Replying to @nthiery:
I'm not saying a metaclass is the right solution, it was just some proposal. That being said, you could think if there are other ways in which your "bag-of-methods" classes differ from "real" classes. Such differences might be handled cleanly by such metaclass. For example, you could use the metaclass to disable automatic binding of methods or to disallow instantiation of the class. |
comment:16
Replying to @nthiery:
I know :-) but sometimes that concise syntax just hides all kinds of stuff which is better made explicit. Like I said before: if I see a |
comment:17
The hypothetical metaclass would also serve as entry point to documentation. If I see
somewhere and want to understand what it does, I could do
which will hopefully explain that this class isn't really a class, but just some syntax to define a dict. I don't know those And this |
comment:18
I know I am repeating myself, but just to clear, I think there are two possible ways:
|
Depends on #20825
Depends on #20686
CC: @nthiery @tscrim
Component: symbolics
Author: Nicolas M. Thiéry
Branch/Commit: u/nthiery/optimize_method_lookup_from_the_categories_for_instances_of_cython_classes @
5619a7d
Issue created by migration from https://trac.sagemath.org/ticket/20859
The text was updated successfully, but these errors were encountered: