On Wed, Nov 16, 2011 at 9:25 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Languages aren't refcounted. Or at least, *Python* isn't a refcounted > language. CPython is a refcounted implementation. IronPython and Jython > are not. del behaves exactly the same in IronPython and Jython as it does > in CPython: it removes the name, which may have a side-effect of deleting > the object.
Yes, I was sloppy there. A non-manually-memory-managed language, if you will; it's part of Python's spec that you do NOT have to explicitly release objects you're no longer using. >> The del >> statement is identical to "a = None" in terms of deleting objects; > > I'm not entirely sure what you arr trying to say here. I *think* you are > trying to say is this: > > Given that `a` is bound to my_object initially, `del a` > from the point of view of my_object is no different > from re-binding a to some other object such as None > (or any other object). > > which is true as far as it goes, but it fails to note that the name "a" > no longer exists after `del a` while it does exist after `a = None`. Right. Both actions have the same effect wrt deleting my_object; the only connection between Python's "del" and C++'s "delete" is that, which del shares with "a = None". The fact is that, regardless of the Python implementation, deleting *objects* is not the programmer's responsibility. The only thing he can or must do is delete *names*. del a del globals()['a'] globals().__delitem__('a') are all roughly equivalent (assuming that a is global). Maybe this is the best way to explain it - that you're deleting from a "dictionary" (which may or may not actually be implemented as a dict) of local names. ChrisA -- http://mail.python.org/mailman/listinfo/python-list