Commit f6d90066 authored by Jason Swails's avatar Jason Swails
Browse files

Possible speedup for unit_math.sum function.

parent 9c38d980
...@@ -156,6 +156,10 @@ def sum(val): ...@@ -156,6 +156,10 @@ def sum(val):
>>> sum((2.0*meter, 30.0*centimeter)) >>> sum((2.0*meter, 30.0*centimeter))
Quantity(value=2.3, unit=meter) Quantity(value=2.3, unit=meter)
""" """
try:
return val.sum()
except AttributeError:
pass
if len(val) == 0: if len(val) == 0:
return 0 return 0
result = val[0] result = val[0]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment