August 22nd, 2005, 05:01 PM
According to answers.com a nanosecond is:
Don't mis-read the exponential within the code tags. Anyways, I'm working with C++ FILETIME structures however I need to use a likelyness of them in Python. There is a certain function which I must create that uses C++ functions such as GetLocalTime() and GetSystemTime(). I've got these functions writen in Python already, since they are easy. The problem is that I cannot convert both of these values into FILETIME structures. Note: It wouldn't be called "structure" in Python. According to MSDN a FILETIME is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). My main concern is retrieving the value of a nanosecond in Python. I'm not sure if it is even possible. If it is not, I will attempt to find a way around this, if it is possible, please show me how to do it or give me an idea. Any help is appreciated.
One billionth (10**-9) of a second.
Edit: Somewhat solved.
I used 10**-9 for a nanosecond. I completely forgot about Python having access to exponential values.
Last edited by †Yegg†; August 22nd, 2005 at 05:17 PM.
August 22nd, 2005, 10:40 PM
Just one quick note: instead of 10**-9 use 1e-9, that's the way to write exponentials in Python
August 22nd, 2005, 10:52 PM
Well, I guess it is. But it still returns the same value.
August 22nd, 2005, 11:09 PM
I know that it returns the same value, but IMO 10**-9 looks ugly (and is probably slower, I'm not sure).
August 23rd, 2005, 02:53 AM
Yes it is:
Originally Posted by mawe
10**-9 will calculate the value every time it is encountered, while 1e-9 will be calculated once at compile time - from the above timings, you can see that 1e-9 takes the same time to evaluate as 1.
$ python -m timeit '10**-9'
1000000 loops, best of 3: 1.75 usec per loop
$ python -m timeit '1e-9'
10000000 loops, best of 3: 0.136 usec per loop
$ python -m timeit '1'
10000000 loops, best of 3: 0.133 usec per loop
Dave - The Developers' Coach
Comments on this post
August 23rd, 2005, 09:09 AM
I guess you guys are right. I'll use 1e-9 instead. Thanks.