Use volatile keyword in _PyTime_AsSecondsDouble()
double
_PyTime_AsSecondsDouble(_PyTime_t t)
{
+ /* volatile avoids optimization changing how numbers are rounded */
+ volatile double d;
+
if (t % SEC_TO_NS == 0) {
_PyTime_t secs;
/* Divide using integers to avoid rounding issues on the integer part.
1e-9 cannot be stored exactly in IEEE 64-bit. */
secs = t / SEC_TO_NS;
- return (double)secs;
+ d = (double)secs;
}
else {
- return (double)t / 1e9;
+ d = (double)t;
+ d /= 1e9;
}
+ return d;
}
PyObject *