time.time() 溢出/翻转 [英] time.time() overflow/rollover

查看:52
本文介绍了time.time() 溢出/翻转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在我的 python 模块中使用 time.time() 来跟踪执行时间并在超时时充当 while 循环转义.

So I am using time.time() in my python module to track execution time and act as a while loop escape upon timeout.

我的问题是 time.time() 何时翻转/溢出.或者是吗?我还没有完全理解 python 数据类型,所以我不确定它可以继续增加多远.

My question is when does time.time() rollover/overflow. Or does it? I don't fully comprehend python datatypes yet, so I am not sure how far it can keep increasing.

推荐答案

需要一段时间.time.time() 返回自 epoch 作为 float.在 UNIX 机器上,纪元通常是 1970-1-1.IIRC,windows 上的纪元是 1601-1-1.

It will be a while. time.time() returns the time in seconds since the epoch as a float. On UNIX machines the epoch is usually 1970-1-1. IIRC, the epoch on windows is 1601-1-1.

根据sys.float_info:

In [2]: sys.float_info
Out[2]: sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)

所以我们有

In [3]: 1.7976931348623157e+308/(3600*24*365.0)
Out[3]: 5.700447535712569e+300

翻滚前几年.:-)

这篇关于time.time() 溢出/翻转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆