|
| 1 | +// The _PyTime_t API is written to use timestamp and timeout values stored in |
| 2 | +// various formats and to read clocks. |
| 3 | +// |
| 4 | +// The _PyTime_t type is an integer to support directly common arithmetic |
| 5 | +// operations like t1 + t2. |
| 6 | +// |
| 7 | +// The _PyTime_t API supports a resolution of 1 nanosecond. The _PyTime_t type |
| 8 | +// is signed to support negative timestamps. The supported range is around |
| 9 | +// [-292.3 years; +292.3 years]. Using the Unix epoch (January 1st, 1970), the |
| 10 | +// supported date range is around [1677-09-21; 2262-04-11]. |
| 11 | +// |
| 12 | +// Formats: |
| 13 | +// |
| 14 | +// * seconds |
| 15 | +// * seconds as a floating pointer number (C double) |
| 16 | +// * milliseconds (10^-3 seconds) |
| 17 | +// * microseconds (10^-6 seconds) |
| 18 | +// * 100 nanoseconds (10^-7 seconds) |
| 19 | +// * nanoseconds (10^-9 seconds) |
| 20 | +// * timeval structure, 1 microsecond resolution (10^-6 seconds) |
| 21 | +// * timespec structure, 1 nanosecond resolution (10^-9 seconds) |
| 22 | +// |
| 23 | +// Integer overflows are detected and raise OverflowError. Conversion to a |
| 24 | +// resolution worse than 1 nanosecond is rounded correctly with the requested |
| 25 | +// rounding mode. There are 4 rounding modes: floor (towards -inf), ceiling |
| 26 | +// (towards +inf), half even and up (away from zero). |
| 27 | +// |
| 28 | +// Some functions clamp the result in the range [_PyTime_MIN; _PyTime_MAX], so |
| 29 | +// the caller doesn't have to handle errors and doesn't need to hold the GIL. |
| 30 | +// |
| 31 | +// Clocks: |
| 32 | +// |
| 33 | +// * System clock |
| 34 | +// * Monotonic clock |
| 35 | +// * Performance counter |
| 36 | +// |
| 37 | +// Operations like (t * k / q) with integers are implemented in a way to reduce |
| 38 | +// the risk of integer overflow. Such operation is used to convert a clock |
| 39 | +// value expressed in ticks with a frequency to _PyTime_t, like |
| 40 | +// QueryPerformanceCounter() with QueryPerformanceFrequency(). |
| 41 | + |
1 | 42 | #ifndef Py_LIMITED_API
|
2 | 43 | #ifndef Py_PYTIME_H
|
3 | 44 | #define Py_PYTIME_H
|
|
0 commit comments