[Libre-soc-bugs] [Bug 324] create POWER9 DIV pipeline

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Fri Jun 19 16:19:39 BST 2020


https://bugs.libre-soc.org/show_bug.cgi?id=324

--- Comment #26 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #25)
> (In reply to Jacob Lifshay from comment #24)
> > 
> > they behave the same as int even if the trunc_div and trunc_rem member
> > functions are overridden with a custom implementation that calculates the
> > same results.
> 
> i'm not understanding you, sorry.  trunc_div and trunc_rem are standalone
> functions not members so cannot be overridden.

The standalone functions tries to call the member functions if they exist, this
is to emulate python's behavior where a - b calls a.__sub__(b) or
b.__rsub__(a).

So, if I had a custom class:

class MyClass:
    def trunc_div(self, d):
        print("trunc_div:", self, "/", d)
        return 0
    def rtrunc_div(self, n):
        print("rtrunc_div:", n, "/", self)
        return 0
    def __repr__(self):
        return "MyClass"

trunc_div(MyClass(), 123)
trunc_div(MyClass(), MyClass())
trunc_div(456, MyClass())

outputs:
trunc_div: MyClass / 123
trunc_div: MyClass / MyClass
rtrunc_div: 456 / MyClass

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list