我想知道为什么python 2.7
使用gettimeofday()
运行时time.time()
但尚未在python 3.4
它不?python time.time()python 2 vs 3的区别
运行strace的,当它看来,它可查询的/ etc /本地时间
我想知道为什么python 2.7
使用gettimeofday()
运行时time.time()
但尚未在python 3.4
它不?python time.time()python 2 vs 3的区别
运行strace的,当它看来,它可查询的/ etc /本地时间
的Python 3将使用gettimeofday()
当检测你的系统来支持这种在编译时。但是,在POSIX系统上,只有在clock_gettime(CLOCK_REALTIME)
不可用时才会使用该功能;根据POSIX 2008 standard,后者是优选的,因为gettimeofday()
被认为是过时的。
在运行时,你可以查询什么的Python认为你的系统可以通过使用time.get_clock_info()
function,它返回一个namedtuple
实例与implementation
场在编译时支持:
实施:底层的名字C函数用来获取时钟值
在我的OSX 10.11体系,为'time'
时钟,产生gettimeofday()
:
>>> time.get_clock_info('time').implementation
'gettimeofday()'
您可以阅读pygettimeofday()
C implementation以查看可以使用哪些实现;例如,在Windows上使用GetSystemTimeAsFileTime()
。
做u面对任何问题呢? –
不同的实现有什么问题吗?添加了各种新的时钟类型后,Python 3'time'模块被彻底检查了。 –
是使用虚拟时间内核https://github.com/littlepretty/VirtualTimeKernel 哪些依赖于GToD – channon