Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104182
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls. |
| Date | 2016-03-07 14:42 +1100 |
| Message-ID | <mailman.5.1457322150.10335.python-list@python.org> (permalink) |
| References | <nbiscc$v96$1@dont-email.me> |
"Veek. M" <vek.m1234@gmail.com> writes: > 1. What are the rules for using __del__ besides: 'don't use it'. What do you mean by “rules”? If you want advice on using that method, I don't think a canonical exhaustive “rules” set exists. For example: Use ‘__del__’ to mark an object as no longer used; don't expect that to result in the object actually going away at any particular point in time. > 2. What happens when I SystemExit? __del__ and gc are not invoked when > I SystemExit and there's a circular reference - but why? So that we can have a concrete example: Can you give a (very minimal and simple) example demonstrating the behaviour, so we can run it too? > 3. > import foo > def __del__(self, foo=foo): > foo.bar() That appears to be a module-level function. It is not a method of any class, so I am not clear on how it relates to garbage collection. > 4. also, are method calls more efficient than function calls? All method calls are function calls. This is because all methods are functions. -- \ “Unix is an operating system, OS/2 is half an operating system, | `\ Windows is a shell, and DOS is a boot partition virus.” —Peter | _o__) H. Coffin | Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
__del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls. "Veek. M" <vek.m1234@gmail.com> - 2016-03-07 08:57 +0530
Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls. Chris Angelico <rosuav@gmail.com> - 2016-03-07 14:38 +1100
Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls. Ben Finney <ben+python@benfinney.id.au> - 2016-03-07 14:42 +1100
Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-03-07 16:56 +1100
Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls. "Veek. M" <vek.m1234@gmail.com> - 2016-03-07 11:43 +0530
Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-03-07 19:37 +1100
Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls. "Veek. M" <vek.m1234@gmail.com> - 2016-03-07 16:56 +0530
csiph-web