Modules/mathmodule.c
Source:
cpython 3.14 @ ab2d84fe1023/Modules/mathmodule.c
Modules/mathmodule.c implements the math module. Most functions are thin wrappers around the C <math.h> functions with Python error handling layered on top. Key additions over plain C: fsum (exact float summation), n-dimensional hypot, comb/perm (exact integer combinatorics), and gcd/lcm (arbitrary number of arguments since Python 3.9).
Map
| Lines | Symbol | Role |
|---|---|---|
| 1-200 | FUNC1, FUNC2 macros | Boilerplate for single/double-arg C math wrappers |
| 201-600 | Trig: sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh, degrees, radians | Trigonometric functions |
| 601-900 | pow, sqrt, exp, log, log2, log10, expm1, log1p | Exponential and logarithm |
| 901-1100 | floor, ceil, trunc, fabs, modf, frexp, ldexp, copysign | Integer-related and decomposition |
| 1101-1400 | fsum | Exact floating-point summation |
| 1401-1700 | isnan, isinf, isfinite, isclose | Float predicates |
| 1701-2000 | hypot (variadic), dist | Distance functions |
| 2001-2400 | factorial, gcd, lcm, comb, perm | Integer combinatorics |
| 2401-3100 | erf, erfc, gamma, lgamma, constants (pi, e, tau, inf, nan) | Special functions and constants |