In the official python documentation in the Data model section, the __ipow__
method is defined as:
object.__ipow__(self, other[, modulo])
Then, the documentation explains that These methods are called to implement the augmented arithmetic assignments (**=
for __ipow__
)
But what is the syntax of **=
that allows to use the modulo
argument ?
The third argument is there just for symmetry with __pow__
.
The argument was included in the original 'add in-place operator equivalents' commit but there is no support to use it from Python code, other than calling the __ipow__
method directly.
For example, the INPLACE_POWER
opcode handling passes in None
as the third argument:
case INPLACE_POWER:
w = POP();
v = TOP();
x = PyNumber_InPlacePower(v, w, Py_None);
Py_DECREF(v);
Py_DECREF(w);
SET_TOP(x);
if (x != NULL) continue;
break;
Most likely it is there to make implementing __ipow__
as an alias for __pow__
trivial even from C code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With