Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81412 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2014-11-23 18:27 -0700 |
| Last post | 2014-11-23 18:27 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: unloading a module created with imp.new_module Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-23 18:27 -0700
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2014-11-23 18:27 -0700 |
| Subject | Re: unloading a module created with imp.new_module |
| Message-ID | <mailman.16215.1416792444.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
On Nov 23, 2014 4:10 AM, "Patrick Stinson" <patrickkidd@gmail.com> wrote:
> m = types.ModuleType('mine')
> exec(s, m.__dict__)
> print('deleting...')
> m = None
> print('done')
>
> and the output is:
>
> deleting...
> done
> __del__
>
> I the “__del__" to come between “deleting…” and “done”. This is not being
run from the interactive interpreter by via a .py file.
This suggests the presence of a reference cycle, since the object is
deleted afterward by the garbage collector. One cycle here is that the
__del__ function has a reference to the module's globals dict, which has a
reference to the class instance, which has a reference to the class, which
has a reference back to the function. There may be other cycles here as
well, but it may also be that the module object itself isn't part of them.
Back to top | Article view | comp.lang.python
csiph-web