I'm using and try/except statement in python inside a very long loop. If the exception is raised, it should do nothing.
try :
*Some Code*
except :
pass
If i use this first proposition, the total time of calculation for the loop is about 10 minutes.
try :
*Some Code*
except :
None
If i use this second propositon, the total time of calculation for the loop is about 2 minutes.
Why is it so different, and why is the second one faster as, logically for me, pass is a better solution than None ?
The exact code is :
try:
indexes = peakutils.peak.interpolate(self.list_height, input_1, ind=indexes, width=self.gauss_width)
except:
None / Pass
I made several tests with both propisitons and it's always the same.
How time is calculated :
start = default_timer()
im.get_events() #The loop where the try/except statement appears
finish = default_timer()
print('ELAPSED TIME : %s'%(finish - start))