Question on periods in strings
Philip Bloom
pbloom at crystald.com
Wed Mar 11 20:35:22 EDT 2009
Hello, this is my first time posting to the list, but my curiosity here
is great.
I was randomly toying with file writes and I ran into something that
seemed quite odd to me. When a period is in a string, file write takes
about double the time. I saw similar things with newlines, but I
figured that was because it was doing a lookup on the escape-d n. All
other symbols seem to not have this problem, so I'm curious what's
special about periods that they take so much longer to write to file.
#Done in python 2.6.1
#runs in 5.8 seconds.
from datetime import datetime
testvar2='9a00'
startTime = datetime.now()
for var in range(10000000):
filehandle.write(testvar2)
filehandle.close()
print (datetime.now() - startTime)
#runs in 10.9 seconds.
from datetime import datetime
testvar2='9.00'
startTime = datetime.now()
for var in range(10000000):
filehandle.write(testvar2)
filehandle.close()
print (datetime.now() - startTime)
Thank you to any who answer for assuaging my curiosity.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090311/392cf1e1/attachment.html>
More information about the Python-list
mailing list