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/2000-December/011137.html below:

[Python-Dev] cycle-GC question

[Python-Dev] cycle-GC questionGuido van Rossum guido@python.org
Tue, 19 Dec 2000 11:01:46 -0500
> might be possible to avoid this circular reference but I don't
> know enough about how RExec works.  Would something like:
> 
>     def add_module(self, mname):
>         if self.modules.has_key(mname):
>             return self.modules[mname]
>         self.modules[mname] = m = self.hooks.new_module(mname)
>         if mname != '__builtin__':
>             m.__builtins__ = self.modules['__builtin__']
>         return m
>     
> do the trick?

That's certainly a good thing to do (__builtin__ has no business
having a __builtins__!), but (in my feeble experiment) it doesn't make
the leaks go away.

Note that almost every module participates heavily in cycles: whenever
you define a function f(), f.func_globals is the module's __dict__,
which also contains a reference to f.  Similar for classes, with an
extra hop via the class object and its __dict__.

--Guido van Rossum (home page: http://www.python.org/~guido/)



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