My question is very simple. I have a python simple code like this :
for i in range(1,1193616,1) :
print i
So all number in range 1 until 1193616 will be printed and this looping progress took a very long time.. How to make it fast ?
EDIT :
actually, i try to make an A-star Pathfinding program for image data (Raster).. This are my A-star function script so far :
def A_star(h,c,dx,dy,u,s_id,e_id,Op,Cl,Prt,CC,o,ht,w):
Op.append(s_id)
while e_id not in Op :
if Op == [ ] :
break
candidate = { }
for i in Op :
d = {i : CC[i]}
candidate.update(d)
o = min(candidate, key=candidate.get)
Cl.append(o)
Op.remove(o)
adjacent_list = adjacent_cell(o,dx,dy )
for p in adjacent_list :
if p in Cl:
adjacent_list = filter(lambda i: i != p, adjacent_list)
elif p not in Op :
Op.append(p)
d = {p : o }
Prt.update(d)
d = {p : F(p,o,h,u,w,c,dx,e_id,ht,CC)}
CC.update(d)
elif id in Op :
f1 = F(p,o,h,u,w,c,dx,e_id,ht,CC)
f2 = F(p,Prt[p],h,u,w,c,dx,e_id,ht,CC)
if f1 < f2 :
d = {p : o }
Prt.update(d)
d = {id : F(p,o,h,u,w,c,dx,e_id,ht,CC)}
CC.update(d)
return Prt
assumed that s_id = 1 (start) and e_id = 1193616 (end), long time looping progress happened on line 3
while e_id not in Op :
Is there any way to accelerate or optimization my code ?