Thanks Alex. I was not aware of mtimeit.
regards, Suresh Alex Martelli wrote: > Suresh Jeevanandam <[EMAIL PROTECTED]> wrote: > >> Hi, >> Is there any gain in performance because of augmented assignments. >> >> x += 1 vs x = x+1 >> >> Or are both of them the same. > > Just *MEASURE*, man! > > helen:~/apy alex$ python -mtimeit -s'x=0.0' 'x=x+1' > 1000000 loops, best of 3: 0.507 usec per loop > > helen:~/apy alex$ python -mtimeit -s'x=0.0' 'x+=1' > 1000000 loops, best of 3: 0.504 usec per loop > > Basically a dead draw, so use what's clearest to you. And learn to use > -mtimeit to satisfy most such curiosities much more effectively. > > > Alex -- http://mail.python.org/mailman/listinfo/python-list