math.pow vs pow
Tim Peters
tim.one at comcast.net
Fri Nov 28 05:48:50 CET 2003
[Clueless Moron]
> Perhaps, but why should pow() be different from math.pow() in python?
The math module wraps the platform C library math functions of the same
names; math.pow() is most useful if you need (or just want) high
compatibility with C extensions calling C's pow().
__builtin__.pow() is the implementation of Python's infix ** operator, and
deals with complex numbers, unbounded integer powers, and modular
exponentiation too (the C pow() doesn't handle any of those).
Over the years, just a few of the math module functions have gotten a bit
smarter than their C namesakes. The primary example is that math.log()
family in recent Pythons returns a sensible result when passed an integer
larger than the biggest platform C double; e.g.,
>>> import math
>>> math.log10(10**4000)
4000.0
>>>
More information about the Python-list
mailing list