`time.perf_counter_ns` always a 64-bit int?

Peter J. Holzer hjp-python at hjp.at
Sat Sep 16 08:28:20 EDT 2023


On 2023-09-15 21:48:37 +0000, rmlibre--- via Python-list wrote:
> I'd like to capture the output of `time.perf_counter_ns()` as an 8-byte
> timestamp.
> 
> I'm aware that the docs provide an undefined start value for that clock.
> I'm going to assume that means it can't be expected to fit within 8
> bytes.

Theoretically this is true. The reference point could be the switch to
the Gregorian calendar in the Vatican, the begin of the Christian era or
the founding of Babylon, all of which were more than 2**63 seconds ago.
However, using one of these dates would be impractical and defeat the
purpose of the performance counters, which are supposed to be high
resolution, monotonic and independent of political influences. So the
reference point is usually the time the system was booted or something
similar.

> However, it would be rather convenient if it could.

Unless you expect your system to have an uptime in excess of 292 years,
don't worry.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20230916/96dcacab/attachment.sig>


More information about the Python-list mailing list