diff -r 58c8cae6c61a Doc/library/cmath.rst --- a/Doc/library/cmath.rst Fri Aug 12 13:21:05 2016 +0000 +++ b/Doc/library/cmath.rst Sun Aug 14 21:13:26 2016 -0700 @@ -253,6 +253,10 @@ The mathematical constant *e*, as a float. +.. data:: tau + + The mathematical constant *τ*, as a float. + .. index:: module: math Note that the selection of functions is similar, but not identical, to that in diff -r 58c8cae6c61a Doc/library/math.rst --- a/Doc/library/math.rst Fri Aug 12 13:21:05 2016 +0000 +++ b/Doc/library/math.rst Sun Aug 14 21:13:26 2016 -0700 @@ -426,6 +426,13 @@ The mathematical constant e = 2.718281..., to available precision. +.. data:: tau + + The mathematical constant τ = 6.283185..., to available precision. + Tau is a circle constant equal to 2π, the ratio of a circle's circumference to + its radius. To learn more about Tau, check out Vi Hart's video `Pi is (still) + Wrong `_, and start celebrating + `Tau day `_ by eating twice as much pie! .. data:: inf diff -r 58c8cae6c61a Include/pymath.h --- a/Include/pymath.h Fri Aug 12 13:21:05 2016 +0000 +++ b/Include/pymath.h Sun Aug 14 21:13:26 2016 -0700 @@ -55,6 +55,12 @@ #define Py_MATH_E 2.7182818284590452354 #endif +/* Tau (2pi) to 40 digits, taken from tauday.com/tau-digits. */ +#ifndef Py_MATH_TAU +#define Py_MATH_TAU 6.2831853071795864769252867665590057683943L +#endif + + /* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU register and into a 64-bit memory location, rounding from extended precision to double precision in the process. On other platforms it does diff -r 58c8cae6c61a Lib/test/test_math.py --- a/Lib/test/test_math.py Fri Aug 12 13:21:05 2016 +0000 +++ b/Lib/test/test_math.py Sun Aug 14 21:13:26 2016 -0700 @@ -197,6 +197,7 @@ def testConstants(self): self.ftest('pi', math.pi, 3.1415926) self.ftest('e', math.e, 2.7182818) + self.assertEqual(math.tau, 2*math.pi) def testAcos(self): self.assertRaises(TypeError, math.acos) diff -r 58c8cae6c61a Modules/cmathmodule.c --- a/Modules/cmathmodule.c Fri Aug 12 13:21:05 2016 +0000 +++ b/Modules/cmathmodule.c Sun Aug 14 21:13:26 2016 -0700 @@ -1239,6 +1239,7 @@ PyModule_AddObject(m, "pi", PyFloat_FromDouble(Py_MATH_PI)); PyModule_AddObject(m, "e", PyFloat_FromDouble(Py_MATH_E)); + PyModule_AddObject(m, "tau", PyFloat_FromDouble(Py_MATH_TAU)); /* 2pi */ /* initialize special value tables */ diff -r 58c8cae6c61a Modules/mathmodule.c --- a/Modules/mathmodule.c Fri Aug 12 13:21:05 2016 +0000 +++ b/Modules/mathmodule.c Sun Aug 14 21:13:26 2016 -0700 @@ -2144,6 +2144,7 @@ PyModule_AddObject(m, "pi", PyFloat_FromDouble(Py_MATH_PI)); PyModule_AddObject(m, "e", PyFloat_FromDouble(Py_MATH_E)); + PyModule_AddObject(m, "tau", PyFloat_FromDouble(Py_MATH_TAU)); /* 2pi */ PyModule_AddObject(m, "inf", PyFloat_FromDouble(m_inf())); #if !defined(PY_NO_SHORT_FLOAT_REPR) || defined(Py_NAN) PyModule_AddObject(m, "nan", PyFloat_FromDouble(m_nan()));