I've noticed some incongruities regarding in-place exponentiation.

On the C side nb_inplace_power is a ternary function, like nb_power (see here: 
http://docs.python.org/c-api/typeobj.html?highlight=numbermethods#PyNumberMethods).

Obviously you can't pass the third argument using the usual in-place syntax 
"**=".
Nevertheless I'd expect to be able to provide the third argument using 
operator.ipow. But the operator module accept only the two parameter variant.

The Number Protocol specify that the ipow operation ""is the equivalent of the 
Python statement o1 **= o2 when o3 is Py_None, or an in-place variant of 
pow(o1, o2, o3) otherwise.""

Since "operator" claims to be contain a "function port" of the operators, I'd 
expect it to implement ipow with three arguments.
I don't see any problem in adding the third argument to it(I mean, sure right 
now any code that calls ipow(a,b,c) [if exists] is broken, because it will just 
raise a TypeError, thus adding the argument will not break any code, and would 
provide more functionality.

Also, I don't think there are many objects in the build-ins or standardlib 
which implement an in-place exponentiation, so this means there wont be much 
code to change.

So my question is: why are there this incongruities?
Is there any chance to see this fixed? (in the operator module, or changing the 
documentation)

By the way: I'm asking this because I'm implementing a C-extension and I'd like 
to implement both pow and ipow. And since it's about polynomials on 
(Z/nZ)[x]/x^r-1, using the third argument always makes sense.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to