memesearch
Print Statements Make Code Slow

Print Statements Make Code Slow

Download Find similar pictures
Text on the meme
a loop with/without print statements is the difference between 2 mins execution time and 2 seconds (5900% more time to execute) please don’t run your code with a lot of print statements unless you’re debugging Tried doing it in a very simple script just for fun, the difference is quite staggering: In large.py: target = open('target.txt', 'w') for item in xrange(4000000): target.write(str(item)+'\n') print item Timing it: gp@imdev1 /tmp$ time python large.py real 1m51.690s user 0m10.531s sys 0m6.129s gp@imdev1 /tmp$ ls -lah target.txt -rw-r--r-- 1 gp gp 39M Nov 8 16:... Now running the same with "print" commented out: gp@imdev1 /tmp$ time python large.py real 0m2.584s user 0m2.536s sys 0m0.040s so i saved $27000/year by removing 10 lines of code this morning they were print() statements
What it means

A screenshot of a social media post explains that repeatedly printing output inside a loop can make a program dramatically slower. A code example compares nearly two minutes with print statements to about two seconds without them, leading to the joke that removing ten print statements saved $27,000 per year. It is shared as a humorous reaction to inefficient debugging code or excessive logging.

Objects
Tags
Source
Type
image
Size
314×800 · 54.0 KiB
Mood
саркастичный, технический
Language
en
Added