[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread malmiteria
> Actually, no, it does not. Only the A.method() runs, because A was not > designed for multiple-inheritance. C inherits from both A and B, but > only calls one of the methods. Yeah, my point was to say that no error is raised, but that the behavior of the program is not really what you'd expec

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread malmiteria
> To me it doesn't seem reasonable that someone would inherit from two > classes and want to call a method from one without even knowing that > there's a method name collision. If you're going to inherit from A and > B, you need to know what methods they provide and you need to think > about t

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Chris Angelico
On Sun, 27 Mar 2022 at 23:03, malmiteria wrote: > > > Actually, no, it does not. Only the A.method() runs, because A was not > > designed for multiple-inheritance. C inherits from both A and B, but > > only calls one of the methods. > > Yeah, my point was to say that no error is raised, but that t

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread malmiteria
> wait, what? > We may need some more clarity as to what you are after. You need SOME > method resolution order, and Python's MRO is pretty simple and straight > froward. You don't need a method resolution *order*, you just need method resolution. That's essentially the punchline. It makes sense

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread malmiteria
C3 linéarization might be mathematically proven to be optimal, as in, it's the best way to order a graph. Sure. But why would we order the inheritance tree? That's essentially my problem with the current solution. looking at conflict, and saying "it's a conflcit" is the correct solution in my mi

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Chris Angelico
On Mon, 28 Mar 2022 at 00:22, malmiteria wrote: > That's my point here. Conflicting names of method existing in both parents > should really be considered a conflict, and require manual solving, as i > illustrated it above. > Where you see "conflicting", I see "overriding" or "augmenting". Can

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread malmiteria
> because that's the entire point of super() -- if you don't want automatic, > do what you want by making direct method calls. Yeah, but current solution is very unknown to most programmers, so they wouldn't know before hand to do that. My solution provides a direct message to the developper tell

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread malmiteria
> Because that is an inconsistent hierarchy, which makes the code > broken, and leads to bugs. Bugs come from the MRO and previous solutions to it. Which i'd argue come from the obsession on that idea that ordering is the way to go. it is not. A solution that can resolve method in what you call

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Chris Angelico
On Mon, 28 Mar 2022 at 00:50, malmiteria wrote: > > > Because that is an inconsistent hierarchy, which makes the code > > broken, and leads to bugs. > Please can you say who you're quoting? You keep quoting these little snippets and then leaving us to figure out who you're responding to. ChrisA

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread malmiteria
I mean, overriding or augmenting is the solution in case of what i would call a conflict. Essentially, a conflict araise when you're trying to access a method of a class that don't define it, and has multiple parent defining it. Todays solution would resolve the child method to the most left of

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread malmiteria
class decorator aren't propagated through inheritance, so i just made it with a good ol' parent class. again, feel free to take a look at my implementation of it here: https://github.com/malmiteria/super-alternative-to-super It's thorougly tested, and hopefully a good showcase of what it does. B

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Eric V. Smith
On 3/26/2022 12:57 PM, malmiteria wrote: what i propose is a solution that would follow those rules: The mro alternative, which i called explicit method resolution aka EMR (which is probably not a good name since i apply it, as mro, to all class attributes), follow those rules : ... 4) Mul

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Stephen J. Turnbull
malmiteria writes: > My alternative to super would, since you can just pass it an > argument telling what parent it should target, it would look like > that > > class A: > def call_me_in_A_first(self): > # don't have to calls super > def call_me_in_B_first(self): > # don't h

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Barry
> On 26 Mar 2022, at 20:19, Christopher Barker wrote: > > Also, super() actually calls the method on all the superclasses (but not the > same one twice) -- so that right to left thing doesn't matter. Super() calls the method on only one class. Not all. It finds that one class by using the m

[Python-ideas] Re: Less is more? Smaller code and data to fit more into the CPU cache?

2022-03-27 Thread Jonathan Fine
Hi Thank you Inada for your prompt and helpful reply. Here's a link for cached hash in bytes object: https://bugs.python.org/issue46864 What I have in mind is making selected objects smaller, for example by using smaller pointers. But how to know the performance benefit this will give? I think i

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Stephen J. Turnbull
malmiteria writes: > Why would this be the order you wanna call all the methods provided > by the parents? It works often. ;-) My guess would be that typical multiple inheritance scenarios are of the form "I want my child class to have the behavior of classes earlier in the declaration order,

[Python-ideas] Re: Less is more? Smaller code and data to fit more into the CPU cache?

2022-03-27 Thread John
Look up Judy arrays. Specialized data structure for this. It's got a simple API, but it's incredibly complex and architecture-specific under the hood. People are always trying to optimize, but there are limits to how much you can do on generic data structures (and how much you can do in general),

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Barry Scott
> On 26 Mar 2022, at 18:15, malmiteria wrote: > > the alternative to super really is not the important part of my proposal, > it's the alternative to MRO. > > An example of a case where i genuinly believe my solution adds value is this : > > ``` > class A: >def method(self): >pr

[Python-ideas] Re: Less is more? Smaller code and data to fit more into the CPU cache?

2022-03-27 Thread Barry Scott
> On 22 Mar 2022, at 15:57, Jonathan Fine wrote: > > Hi > > As you may have seen, AMD has recently announced CPUs that have much larger > L3 caches. Does anyone know of any work that's been done to research or make > critical Python code and data smaller so that more of it fits in the CPU >

[Python-ideas] Re: Less is more? Smaller code and data to fit more into the CPU cache?

2022-03-27 Thread Barry Scott
> On 27 Mar 2022, at 18:16, Jonathan Fine wrote: > > Hi > > Thank you Inada for your prompt and helpful reply. Here's a link for cached > hash in bytes object: https://bugs.python.org/issue46864 > > > What I have in mind is making selected objects smalle

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Steven D'Aprano
On Sun, Mar 27, 2022 at 01:33:05PM -, malmiteria wrote: > C3 linéarization might be mathematically proven to be optimal, as in, > it's the best way to order a graph. Sure. But why would we order the > inheritance tree? How else are you going to get inheritance without a linear order? The

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Steven D'Aprano
It seems to me that perhaps what you want is not multiple inheritance in its full generality, but a restricted version called "Traits". Michele Simionato has blogged about this. Unfortunately, Artima seems to be down right now, but hopefully they will be back soon and you can look for Michele's

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Steven D'Aprano
Artima is still broken, but some links are working. You can start here: https://www.artima.com/weblogs/viewpost.jsp?thread=246488 There is a whole series of posts on super, the mro, multiple inheritance, mixins and traits, but I don't have direct URLs to the posts so until Artima fix their webs

[Python-ideas] Re: mro and super don't feel so pythonic

2022-03-27 Thread Chris Angelico
On Mon, 28 Mar 2022 at 10:41, Steven D'Aprano wrote: > > On Sun, Mar 27, 2022 at 01:33:05PM -, malmiteria wrote: > > > C3 linéarization might be mathematically proven to be optimal, as in, > > it's the best way to order a graph. Sure. But why would we order the > > inheritance tree? > > How e