Is there a way to customise math.sqrt(x) for some x?
Peter Otten
__peter__ at web.de
Sat Jul 16 05:37:18 EDT 2011
Steven D'Aprano wrote:
> I have a custom object that customises the usual maths functions and
> operators, such as addition, multiplication, math.ceil etc.
>
> Is there a way to also customise math.sqrt? I don't think there is, but I
> may have missed something.
There seem to be only three methods that can be customized:
$ grep 'LookupSpecial' mathmodule.c
method = _PyObject_LookupSpecial(number, "__ceil__", &ceil_str);
method = _PyObject_LookupSpecial(number, "__floor__", &floor_str);
trunc = _PyObject_LookupSpecial(number, "__trunc__", &trunc_str);
More information about the Python-list
mailing list