为什么 python timeit 检查 win32 而不是 win*?
Why does python timeit check for win32 instead of win*?
我的 timeit
来源 (python 2.7) 有
if sys.platform == "win32":
# On Windows, the best timer is time.clock()
default_timer = time.clock
else:
# On most other platforms the best timer is time.time()
default_timer = time.time
然而文档表明所有 Windows 机器的行为都相同
The difference in default timer function is because on Windows,
clock() has microsecond granularity but time()'s granularity is 1/60th
of a second...
64 位 Windows 会发生什么? time.time
在 64 位 Windows 上实际上更好吗?
看来连 64 位 windows 都会告诉你它的平台是 "win32"。我在 64 位 Windows 7 系统上,这是我看到的:
>>> import sys
>>> sys.platform
'win32'
因此,64 位 Windows 也将使用 time.clock
。
我的 timeit
来源 (python 2.7) 有
if sys.platform == "win32":
# On Windows, the best timer is time.clock()
default_timer = time.clock
else:
# On most other platforms the best timer is time.time()
default_timer = time.time
然而文档表明所有 Windows 机器的行为都相同
The difference in default timer function is because on Windows, clock() has microsecond granularity but time()'s granularity is 1/60th of a second...
64 位 Windows 会发生什么? time.time
在 64 位 Windows 上实际上更好吗?
看来连 64 位 windows 都会告诉你它的平台是 "win32"。我在 64 位 Windows 7 系统上,这是我看到的:
>>> import sys
>>> sys.platform
'win32'
因此,64 位 Windows 也将使用 time.clock
。