time.time() strangeness

N

Nitro

Hello,

today I encountered a very odd situation. I am on Windows Vista and using
Python 2.5.2. Here's a code snippet to illustrate my problem:

# uncomment the next line to trigger the problem
# myExtensionModule.CreateDirect3D9Device()
import time
for i in range(0,100):
print time.time()

With the line commented time.time() returns a changing value which is what
I expect. However, when I uncomment it and create a Direct3D9 Device
[1][2] it keeps printing the very same number over and over! In my project
I am using twisted which uses time.time() to schedule all calls. Since
time.time() is completely screwed the whole application breaks.
I took a look at [3], but I can't see any obivous way how this all
interacts. Specifically I am not sure which API time.time() uses
internally (timeGetTime maybe?). Knowing this could probably help me debug
more. I feel like time.time() should not break (unless the vid card
driver/directx has a major bug). Any idea what might be happening here?
Replacing time.time() with time.clock() in twisted.python.runtime makes
the problem disappear. I guess because it uses QueryPerformanceCounter.

Thanks for your time,
-Matthias

References:
[1] http://msdn2.microsoft.com/en-us/library/bb172527(VS.85).aspx
[2] http://msdn2.microsoft.com/en-us/library/bb172527(VS.85).aspx
[3]
http://svn.python.org/view/python/trunk/Modules/timemodule.c?rev=59678&view=markup
 
P

Paul Rubin

Nitro said:
With the line commented time.time() returns a changing value which is
what I expect. However, when I uncomment it and create a Direct3D9
Device [1][2] it keeps printing the very same number over and over!

The granularity of time.time can be quite large, maybe as much
as 1 second in some systems. Also, if the user can set the time,
the output might not be monotone. They might set the clock backwards
if it has drifted ahead, or something like that. Better to use an
explicit counter if you need a monotonically increasing sequence.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

time.time() strangeness 2
time.time() strangeness 0
Need some help porting from C# 2
data type 1
Structured exception 1
Missing '}' on MSDN 3
Identity of asp_wp.exe 3
HtmlEncode for all controls 7

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top