[Python-Dev] A cute new way to get an infinite loop (original) (raw)
Tim Peters tim.peters at gmail.com
Thu Sep 23 20:11:34 CEST 2004
- Previous message: [Python-Dev] A cute new way to get an infinite loop
- Next message: [Python-Dev] A cute new way to get an infinite loop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Marek Baczek BaczyĆski]
Doesn't it leak memory when Ctrl+C'd (on Windows at least?)
Not really. "Leak" is reserved for cases where memory is unaccounted for. In this case, the memory is consumed by the ever-growing list:
x = [1] x.extend(-y for y in x) Traceback (most recent call last): File "", line 1, in ? File "", line 1, in KeyboardInterrupt len(x) 67090195 x[:10] [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]
At that point, doing
del x[:]
reclaimed a few hundred megabytes.
- Previous message: [Python-Dev] A cute new way to get an infinite loop
- Next message: [Python-Dev] A cute new way to get an infinite loop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]