> -----Original Message----- > From: Mark Hammond [mailto:mhamm...@skippinet.com.au] > Sent: 22. október 2009 10:58 > To: Kristján Valur Jónsson > Cc: Scott Dial; python-dev@python.org > It was made in the context of the APIs available to implement this. > The > code is short-and-sweet in timemodule.c, so please do go ahead and fix > my flawed reasoning.
... I'm sorry, I don't want to start a flame war here, it just seems that if you need a zero point, and arbitrarily choose the first call to time.clock(), you could just as well use the implicit zero point already provided by the system. > -----Original Message----- > From: python-dev-bounces+kristjan=ccpgames....@python.org > [mailto:python-dev-bounces+kristjan=ccpgames....@python.org] On Behalf > Of M.-A. Lemburg > I'm not sure I understand why time.clock() should be considered > broken. Ah, well, not broken, but it could be even more useful: If it used the implicit system-wide epoch rather than the one based on the first call within each process, it could be useful for cross-process high-resolution timings. Anyway, it is simple enough to patch it on windows using ctypes if one needs that kind of behaviour: #nuclock.py import ctypes import time counter = ctypes.c_uint64() pcounter = ctypes.byref(counter) ctypes.windll.kernel32.QueryPerformanceFrequency(pcounter) frequency = float(counter.value) QPC = ctypes.windll.kernel32.QueryPerformanceCounter def nuclock(): QPC(pcounter) return float(counter.value)/frequency time.clock = nuclock Cheers, Kristjan _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com