time.time() strangeness

Ross Ridge rridge at caffeine.csclub.uwaterloo.ca
Tue Feb 26 23:28:18 CET 2008

Nitro  <nitro at dr-code.org> wrote:
>I can tell you more now. If I pass D3DCREATE_FPU_PRESERVE while creating  
>the DirectX device the bug does not appear. This flag means "Direct3D  
>defaults to single-precision round-to-nearest" (see [1]) mode.
>Unfortunately it is not an option to pass this flag, I need the  
>performance boost it gives.

Using D3DCREATE_FPU_PRESERVE is extreamly unlikely to affect the
performance of your code.  Almost all 3D computation these days is done
either on the video card or using SSE math on the CPU, neither which is
affected by the use of this flag and the state of the FPU's precision
setting.  If you're mixing Python and Direct3D I would strongly recommend
using D3DCREATE_FPU_PRESERVE.  It will save you a lot of headaches
because time.time() is probably not the only thing that will break.

>Can somebody tell me how this interacts with python's time.time()? I  
>suppose it's some kind of double vs. float thing or some fpu asm code  

If you let Direct3D change the FPU settings, then the calculation made to
compute the floating-point value returned by time.time() gets rounded to
a 32-bit single-precision floating-point value.  This means that number
returned by time.time() only has 24 bits of precision, which for current
time values, only gives you an accuracy of a hundred seconds or so.

					Ross Ridge

 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge at csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  

More information about the Python-list mailing list