[pypy-commit] pypy py3.6: Add math.tau

amauryfa pypy.commits at gmail.com
Wed Jan 3 17:54:51 EST 2018


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3.6
Changeset: r93619:6190ca28a930
Date: 2017-12-25 19:08 +0100
http://bitbucket.org/pypy/pypy/changeset/6190ca28a930/

Log:	Add math.tau

diff --git a/pypy/module/math/__init__.py b/pypy/module/math/__init__.py
--- a/pypy/module/math/__init__.py
+++ b/pypy/module/math/__init__.py
@@ -11,6 +11,7 @@
     interpleveldefs = {
        'e'              : 'interp_math.get(space).w_e',
        'pi'             : 'interp_math.get(space).w_pi',
+       'tau'            : 'interp_math.get(space).w_tau',
        'inf'            : 'interp_math.get(space).w_inf',
        'nan'            : 'interp_math.get(space).w_nan',
        'pow'            : 'interp_math.pow',
diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py
--- a/pypy/module/math/interp_math.py
+++ b/pypy/module/math/interp_math.py
@@ -10,6 +10,7 @@
     def __init__(self, space):
         self.w_e = space.newfloat(math.e)
         self.w_pi = space.newfloat(math.pi)
+        self.w_tau = space.newfloat(math.pi * 2.0)
         self.w_inf = space.newfloat(rfloat.INFINITY)
         self.w_nan = space.newfloat(rfloat.NAN)
 def get(space):
diff --git a/pypy/module/math/test/test_math.py b/pypy/module/math/test/test_math.py
--- a/pypy/module/math/test/test_math.py
+++ b/pypy/module/math/test/test_math.py
@@ -380,3 +380,7 @@
         assert math.isinf(math.inf)
         assert math.inf > -math.inf
         assert math.isnan(math.nan)
+
+    def test_pi_tau(self):
+        import math
+        assert math.tau == math.pi * 2.0


More information about the pypy-commit mailing list