[Python-checkins] r60418 - in python/branches/trunk-math: Doc/library/math.rst Modules/mathmodule.c

christian.heimes python-checkins at python.org
Tue Jan 29 17:18:09 CET 2008


Author: christian.heimes
Date: Tue Jan 29 17:18:09 2008
New Revision: 60418
Modified:
 python/branches/trunk-math/Doc/library/math.rst
 python/branches/trunk-math/Modules/mathmodule.c
Log:
Removed the optional base argument from log1p().
Modified: python/branches/trunk-math/Doc/library/math.rst
==============================================================================
--- python/branches/trunk-math/Doc/library/math.rst	(original)
+++ python/branches/trunk-math/Doc/library/math.rst	Tue Jan 29 17:18:09 2008
@@ -131,10 +131,9 @@
 *base* argument added.
 
 
-.. function:: log1p(x[, base])
+.. function:: log1p(x)
 
- Return the logarithm of *1+x* to the given *base*. If the *base* is not specified,
- return the natural logarithm of *1+x* (that is, the logarithm to base *e*). The
+ Return the natural logarithm of *1+x* (base *e*). The
 result is calculated in a way which is accurate for *x* near zero.
 
 .. versionadded:: 2.6
@@ -297,4 +296,3 @@
 
 Module :mod:`cmath`
 Complex number versions of many of these functions.
-
Modified: python/branches/trunk-math/Modules/mathmodule.c
==============================================================================
--- python/branches/trunk-math/Modules/mathmodule.c	(original)
+++ python/branches/trunk-math/Modules/mathmodule.c	Tue Jan 29 17:18:09 2008
@@ -401,35 +401,13 @@
 If the base not specified, returns the natural logarithm (base e) of x.");
 
 static PyObject *
-math_log1p(PyObject *self, PyObject *args)
+math_log1p(PyObject *self, PyObject *arg)
 {
-	PyObject *arg;
-	PyObject *base = NULL;
-	PyObject *num, *den;
-	PyObject *ans;
-
-	if (!PyArg_UnpackTuple(args, "log1p", 1, 2, &arg, &base))
-		return NULL;
-
-	num = loghelper(arg, log1p, "log");
-	if (num == NULL || base == NULL)
-		return num;
-
-	den = loghelper(base, log1p, "log");
-	if (den == NULL) {
-		Py_DECREF(num);
-		return NULL;
-	}
-
-	ans = PyNumber_Divide(num, den);
-	Py_DECREF(num);
-	Py_DECREF(den);
-	return ans;
+	return loghelper(arg, log1p, "log1p");
 }
 
 PyDoc_STRVAR(math_log1p_doc,
-"log1p(x[, base]) -> the logarithm of 1+x to the given base.\n\
-If the base not specified, returns the natural logarithm (base e) of x.\n\
+"log1p(x) -> the natural logarithm of 1+x (base e).\n\
 The result is computed in a way which is accurate for x near zero.");
 
 static PyObject *
@@ -580,7 +558,7 @@
 	{"isnan",	math_isnan,	METH_O,		math_isnan_doc},
 	{"ldexp",	math_ldexp,	METH_VARARGS,	math_ldexp_doc},
 	{"log",		math_log,	METH_VARARGS,	math_log_doc},
-	{"log1p",	math_log1p,	METH_VARARGS,	math_log1p_doc},
+	{"log1p",	math_log1p,	METH_O,		math_log1p_doc},
 	{"log10",	math_log10,	METH_O,		math_log10_doc},
 	{"modf",	math_modf,	METH_O,		math_modf_doc},
 	{"pow",		math_pow,	METH_VARARGS,	math_pow_doc},


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /