Posted inmath
How to calculate absolute values with math.fabs in Python
Python's abs() and math.fabs() are not interchangeable. The built-in abs() correctly handles complex numbers and custom objects via the __abs__() method. In contrast, math.fabs() only accepts real numbers and will raise a TypeError otherwise. For integers, abs() is also often significantly faster.
