Message79670
| Author |
pitrou |
| Recipients |
ocean-city, pitrou |
| Date |
2009年01月12日.12:21:41 |
| SpamBayes Score |
0.0 |
| Marked as misclassified |
No |
| Message-id |
<1231762902.14.0.443502484483.issue4921@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Since g calls "itself" in its own scope, it is stored as one of its own
cell vars, which creates a reference cycle. a is also part of its
reference cycle for the same reason, so it must wait for garbage
collection to be reclaimed.
If g didn't keep a reference to its cell vars, closures wouldn't be
possible, because the cell vars wouldn't survive the end of f's scope.
(g doesn't have to be recursive, it's enough that it makes a reference
to itself in its own scope:
def f():
a = A()
def g():
a
g
or even:
def f():
a = A()
def g():
a
h
h = g
) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2009年03月09日 14:33:58 | georg.brandl | set | spambayes_score: 0.673817 -> 0.0 |
| 2009年01月12日 12:21:42 | pitrou | set | recipients:
+ pitrou, ocean-city |
| 2009年01月12日 12:21:42 | pitrou | set | messageid: <1231762902.14.0.443502484483.issue4921@psf.upfronthosting.co.za> |
| 2009年01月12日 12:21:41 | pitrou | link | issue4921 messages |
| 2009年01月12日 12:21:41 | pitrou | create |
|