Open
Description
Description
Today I found out that there are two ways to define an infinity floating variable in Python:
math.inf
float("inf")
After quick testing it seems that they produce exactly the same object, but math.inf
is 2-3 times faster. On top of that math.inf
is shorter than float("inf")
. Lastly, I think math.inf
looks more pythonic than float("inf")
, but that might be more personal.
Should we add a Ruff rule to prefer math.inf
over float("inf")
(and -math.inf
over float("-inf")
)
Keywords:
- math.inf
- float("inf")
- infinity