Skip to content

Instantly share code, notes, and snippets.

@xymor
Created January 29, 2015 20:18
Show Gist options
  • Save xymor/f77de8ad38388590d26a to your computer and use it in GitHub Desktop.
Save xymor/f77de8ad38388590d26a to your computer and use it in GitHub Desktop.
Python print performance
import sys
import time
x = 1
start_time = time.time()
for l in range(100000):
print x
print time.time() - start_time
# for x = 0.3333 -> time 1.79656600952
# for x = 1 -> time 0.50
So if precision isn't important or you're only considering Ints, use int(round(x)) and make your print 3x faster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment