Commits

Armin Rigo  committed f1fb181

Special-case "x ** 2" here instead.

  • Participants
  • Parent commits 937fb53

Comments (0)

Files changed (1)

File pypy/objspace/std/floatobject.py

     y = w_float2.floatval
 
     # Sort out special cases here instead of relying on pow()
+    if y == 2.0:                      # special case for performance:
+        return W_FloatObject(x * x)   # x * x is always correct
     if y == 0.0:
         # x**0 is 1, even 0**0
         return W_FloatObject(1.0)