Question on periods in strings

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Mar 12 03:42:15 EDT 2009


En Wed, 11 Mar 2009 23:42:45 -0200, Philip Bloom <pbloom at crystald.com>  
escribió:

> Thanks for the welcome :)
>
> You're right.  Here's with the missed line (I was cutting out commented  
> parts).  Hopefully these are all cut/paste-able.
>
> #test A
> #runs in 5.8 seconds.
> from datetime import datetime
> testvar2='9a00'
> startTime = datetime.now()
> filehandle=open('testwriting.txt','w')
> for var in range(10000000):
>     filehandle.write(testvar2)
> filehandle.close()
> print (datetime.now() - startTime)
>
>
> #test B
> [using '9.00' -- otherwise identical]
>
> I do use the same filename, but I've run the tests in different orders  
> and it's made no difference.  Repeatedly running the same test results  
> in the same numbers with only minor fluctuations (as would be expected  
> from cache issues).  Ten runs in a row of Test B all result in about 11  
> seconds each.  Ten runs in a row of Test A all result in about 6 seconds  
> each.

I could not reproduce this. You've got better hardware than mine,  
certainly (I had to remove a 0 to get reasonable times) but I got almost  
identical results with both versions. I've tested also with 3.0 (and I had  
to take another 0 off!) with the same results.
I have no idea why you see a difference. Unless the antivirus is  
interfering, or you have some crazy driver monitoring disk activity and  
the dot triggers something...
Try using a different language - I'd say this is totally unrelated to  
Python.

-- 
Gabriel Genellina




More information about the Python-list mailing list