[Python-Dev] statically nested scopes

Greg Ewing greg@cosc.canterbury.ac.nz
Mon, 06 Nov 2000 14:16:27 +1300 (NZDT)

"M.-A. Lemburg" <mal@lemburg.com>:

> Nested scopes will introduce cycles in all frame objects.

It doesn't have to be that way. A static link is only
needed if a function actually uses any variables from
an outer scope. In the majority of cases, it won't.

And it's possible to do even better than that. You can
separate out variables referred to in an inner scope
and store them separately from the rests of the frame,
so you only keep what's really needed alive.

> This means that with GC turned off, frame objects will live
> forever

Don't allow GC to be turned off, then! (Presumably this
feature would only be considered once GC has become a
permanent feature of Python.)

> BTW, Python's GC only works for a few builtin types (frames
> are not among the supported types)

But they could become so if necessary, surely?

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+