daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2.  
  3. # python3.6.1: `%s` is 10 tiems faster than `format`
  4. >>> t1=time.time();c=['%s %s' %(1, 2) for i in range(10000)];time.time()-t1
  5. 0.0005083084106445312
  6. >>> t1=time.time();c=['{0} {1}'.format(1, 2) for i in range(10000)];time.time()-t1
  7. 0.005129098892211914
  8.  
  9. # python2.7.10 `%s` is 2 tiems faster than `format`
  10. >>> t1=time.time();c=['{0} {1}'.format(1, 2) for i in range(10000)];time.time()-t1
  11. 0.00415802001953125
  12. >>> t1=time.time();c=['%s %s' %(1, 2) for i in range(10000)];time.time()-t1
  13. 0.002238035202026367
  14.  
  15. # Python3 VS Python2: `%s` is faster, and `format` is slower
RAW Paste Data
Top