3-arg float pow()
Tim Peters
tim.one at home.com
Mon Sep 3 03:05:53 EDT 2001
Python's builtin 3-argument pow() exists because, e.g.,
>>> pow(3L, 500, 7)
2L
>>>
can be done very much faster, and with much less memory, than
>>> 3L**500 % 7
2L
>>>
There isn't any compelling use I know of for 3-arg pow() given float
arguments, though, and what you get back is a platform-dependent accident:
>>> pow(3., 500., 7.)
4.0
>>>
You may get some other integer there, or an Infinity or a NaN, depending on
the Python release, and the compiler used to build Python, and the
configuration of your libm. That example was done under CVS 2.2a2+ on
Windows; here's the same thing but under 2.2.1:
>>> pow(3., 500., 7.)
0.0
>>>
Since 3-argument float pow() *appears* to be at best useless, I'm taking it
away in 2.2a3, unless someone can testify to a reasonable use case that's
actually used.
more-trouble-than-it's-worth-if-it-isn't-worth-anything-ly y'rs - tim
More information about the Python-list
mailing list