[Python-Dev] PEP 410 (Decimal timestamp): the implementation is ready for a review (original) (raw)
Mark Shannon mark at hotpy.org
Wed Feb 15 21:15:52 CET 2012
- Previous message: [Python-Dev] PEP 410 (Decimal timestamp): the implementation is ready for a review
- Next message: [Python-Dev] PEP 410 (Decimal timestamp): the implementation is ready for a review
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Antoine Pitrou wrote:
On Wed, 15 Feb 2012 20:56:26 +0100 "Martin v. Löwis" <martin at v.loewis.de> wrote:
With the quartz in Victor's machine, a single clock takes 0.3ns, so three of them make a nanosecond. As the quartz may not be entirely accurate (and also as the CPU frequency may change) you have to measure the clock rate against an external time source, but Linux has implemented algorithms for that. On my system, dmesg shows
[ 2.236894] Refined TSC clocksource calibration: 2793.000 MHz. [ 2.236900] Switching to clocksource tsc But that's still not meaningful. By the time clockgettime() returns, an unpredictable number of nanoseconds have elapsed, and even more when returning to the Python evaluation loop. So the nanosecond precision is just an illusion, and a float should really be enough to represent durations for any task where Python is suitable as a language.
I reckon PyPy might be able to call clock_gettime() in a tight loop almost as frequently as the C program (although not with the overhead of converting to a decimal).
Cheers, Mark.
- Previous message: [Python-Dev] PEP 410 (Decimal timestamp): the implementation is ready for a review
- Next message: [Python-Dev] PEP 410 (Decimal timestamp): the implementation is ready for a review
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]