Why they use this: duration = time.time() - self.start_time + 1
On Sun, Aug 4, 2019 at 12:36 PM Hongyi Zhao <hongyi.zhao at gmail.com> wrote:
> I read the code here:
> It said in line 244:
> duration = time.time() - self.start_time + 1
> I'm very confusing why it used like this instead of the following:
> duration = time.time() - self.start_time
My guess is that it's an easy way to ensure that you never divide by
zero (assuming monotonic time, which time.time() doesn't guarantee).
On systems where the normal "get time" function returns an integer of
seconds, adding one also forms an easy way to "round up" and include
both the starting second and the ending second; but in Python, you get
a float with subsecond resolution, so that doesn't really apply.
BTW, I was somewhat amused to see a question about TIME in a file
named "Homura". Turns out that it actually IS named after who I think
it is. Hah.