Sept. 23, 2004
6:11 p.m.
[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 "<stdin>", line 1, in ? File "<stdin>", line 1, in <generator expression> 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.