import io
from time import clock
def stopwatch(func):
def wrapper(file, mode):
clock()
func(file, mode)
print(clock())
return wrapper
@stopwatch
def checkSimpleOpen(file, mode):
with open(file, mode) as f:
f.write("TEST")
@stopwatch
def checkIoOpen(file, mode):
with io.open(file, mode) as f:
f.write("TEST")
# checkSimpleOpen("__f.txt", "w")
checkIoOpen("__f.txt", "w")
0.0011816 - open
0.0007031 - io.open
56055054099048010104805704505504801020550450520490570480450970980510970450500530520980540101053010205205404901010
56055054099048010104805704505504801020550450520490570480450970980510970450500530520980540101053010205205404901010
ced2522ad3f8f96c369c57eba5c766ee