Simon King
unread,Sep 21, 2019, 4:44:28 AM9/21/19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sage-...@googlegroups.com
Hi!
Let R be a ring that is an F-vector space, for some field F.
Let x,y be elements of R and c be an element of F.
If I understand correctly, in order to implement x/y, one should provide
a single underscore method x._div_. But what should one provide for x/c?
It seems that the default behaviour is to replace x/c by x*(~c), but
for efficiency I don't want that c is inverted in F before letting it
act on x.
Moreover, in my use case, R is not an integral domain (thus, has no fraction
field), and actually I don't want division in R at all. So, what do I
need to do in order to make x/y NOT work (and fail with a TypeError)?
In the above situation, is it recommended to override double underscore
__div__? Then what about Py3? Would it then be needed to override
__div__, __truediv__ and __floordiv__?
Best regards,
Simon