A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-September/049062.html below:

[Python-Dev] A cute new way to get an infinite loop

[Python-Dev] A cute new way to get an infinite loopTim Peters tim.peters at gmail.com
Thu Sep 23 20:11:34 CEST 2004
[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.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4