#
import time
start = time.clock()
mylist = [(x * x) for x in range(3000000)]
for i in mylist:
pass
stop = time.clock()
print stop-start
start = time.clock()
mygenerator = (x * x for x in range(3000000))
for i in mygenerator:
pass
stop = time.clock()
print stop-start
start = time.clock()
def createGenerator():
mylist = range(3000000)
for i in mylist:
yield i * i
mygenerator = createGenerator() # create a generator
#print(mygenerator) # mygenerator is an object!
for i in mygenerator:
pass
stop = time.clock()
print stop-start
#
#
value = raw_input()
def p_arr(str):
arr = str.split(',')
count = len(arr)
for item in arr:
print item
return count
print str(p_arr(value)) + ";;;"
result::::::::::::::
PS D:\Projects\Python.Projects\maths> python main.py
0.92048384
0.706350506667
0.705092266667
bor
bor
1;;;
PS D:\Projects\Python.Projects\maths>
No comments:
Post a Comment