Python ipow: how to use third argument?
In the official python documentation under Data Model, the method is defined as: __ipow__
object.__ipow__(self, other[, modulo])
The documentation then explains what these methods are called to implement extended arithmetic assignments ( **=
for __ipow__
)
But what is the syntax **=
that allows you to use an argument modulo
?
source to share
The third argument exists only for symmetry with __pow__
.
The argument was included in the original 'adding local operator equivalents , but there is no support for using it from Python code other than calling a method __ipow__
.
For example, INPLACE_POWER
opcode processing takes placeNone
in 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 should make the implementation __ipow__
as an alias for __pow__
trivial even from C code.
source to share