fork(9) download
  1. from timeit import timeit
  2. print '{:<12}\t{:.3}s'.format('str.zfill()', timeit("'6'.zfill(8)"))
  3. print '{:<12}\t{:.3}s'.format('str.format()', timeit("'{0:08b}'.format(6)"))
  4. print '{:<12}\t{:.3}s'.format('format()', timeit("format(6, '08b')"))
Success #stdin #stdout 1.59s 8144KB
stdin
Standard input is empty
stdout
str.zfill() 	0.288s
str.format()	0.673s
format()    	0.619s