Comment on quick explanation
Etterra@discuss.online 1 day agoDoes that loop infinitely? Because if it does Reddit needs to know ALL about it.
Comment on quick explanation
Etterra@discuss.online 1 day agoDoes that loop infinitely? Because if it does Reddit needs to know ALL about it.
cypherpunks@lemmy.ml 1 day ago
The first version I posted would loop infinitely… if you have infinite RAM, that is 🫠 (the string will reach 1KB after 30 iterations, and 1MB after 60, 2MB after 63, and so on).
Fortunately the rate of memory consumption is not too fast because python string replacement is very slow when the string in the megabytes range, but due to your comment, to avoid eventually crashing someone’s computer if they fail to hit ctrl-c, i’ve now edited it to stop after 60 iterations.
here is the original which will in fact run until it runs out of memory:
python -c ‘import itertools as I,time as t;a=“o”;[(print(a),a:=a.replace(*[“o”,“O”,“8”,“oo”][i%3:i%3+2]),t.sleep(max(.3,1-(i/50))))for i in I.count()]’if you don’t hit ctrl-c before consumes all of your RAM, you will be at the mercy of your operating system’s out-of-memory-killer… if it decides to kill something other than this python process you might have a bad time.