I'm trying to create a custom class that behaves like an integral numeric type. The straightforward way to do that is to consult Python3 documentation on the matter, and then implement all the magic functions: both arithmetic __add__, __radd__, __sub__, ... and comparison __le__, __lt__, ... operators.
However, implementing them all by hand is tedious. I believe that in many cases, a good enough solution would be to implement them automatically based on the __int__ magic function: we simply do the arithmetic with the object converted to int. Is this part of any commonly used library? What I'm looking for is something similar to @functools.total_ordering, which automatically derives all comparison operators from only one of the operators.
If there is no such thing, then why? Would it be a bad idea to have such automatic conversion, or is it simply an issue one does not encounter too often?
Edit: In case that the details of the custom class are relevant, I provide some of them here.
What I'm constructing is a counter whose value can change not only through arithmetic operations, but also other means. These can be very general: for example, we can tell the counter the following: "If anybody asks you what value you represent, return twice the normal value."
To illustrate, suppose you're playing a board game, for example, similar to Civilization. The game makes use of many parts, one of them is the counter that counts the military strength your civilization has. However, there may be an in-game effect which causes each point of strength to count twice.
Since the class is required to be mutable, I believe subclassing int is not an option (as int is immutable).
int?