Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15750

Re: Extracting elements over multiple lists?

References (3 earlier) <4EB828B3.1020509@sequans.com> <5B80DD153D7D744689F57F4FB69AF4740182FE@SCACMX008.exchad.jpmchase.net> <4EC2ACCC.2000100@davea.name> <mailman.2745.1321386809.27778.python-list@python.org> <4ec2e6cb$0$29970$c3e8da3$5496439d@news.astraweb.com>
Date 2011-11-16 09:54 +1100
Subject Re: Extracting elements over multiple lists?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2756.1321397658.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Nov 16, 2011 at 9:25 AM, Steven D'Aprano
<steve+comp.lang.python@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Extracting elements over multiple lists? JoeM <josephmeiring@gmail.com> - 2011-11-07 09:12 -0800
  Re: Extracting elements over multiple lists? John Gordon <gordon@panix.com> - 2011-11-07 17:37 +0000
  Re: Extracting elements over multiple lists? Laurent Claessens <moky.math@gmail.com> - 2011-11-07 18:44 +0100
    Re: Extracting elements over multiple lists? JoeM <josephmeiring@gmail.com> - 2011-11-07 10:01 -0800
      Re: Extracting elements over multiple lists? John Gordon <gordon@panix.com> - 2011-11-07 18:22 +0000
        Re: Extracting elements over multiple lists? Terry Reedy <tjreedy@udel.edu> - 2011-11-07 19:06 -0500
      Re: Extracting elements over multiple lists? Peter Otten <__peter__@web.de> - 2011-11-07 19:33 +0100
      Re: Extracting elements over multiple lists? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-11-07 19:51 +0100
      Re: Extracting elements over multiple lists? Dave Angel <d@davea.name> - 2011-11-07 15:06 -0500
      Re: Extracting elements over multiple lists? Laurent Claessens <moky.math@gmail.com> - 2011-11-08 08:07 +0100
      RE: Extracting elements over multiple lists? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2011-11-15 17:01 +0000
        Re: Extracting elements over multiple lists? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-15 22:21 +0000
      Re: Extracting elements over multiple lists? Dave Angel <d@davea.name> - 2011-11-15 13:17 -0500
      Re: Extracting elements over multiple lists? Chris Angelico <rosuav@gmail.com> - 2011-11-16 06:53 +1100
        Re: Extracting elements over multiple lists? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-15 22:25 +0000
          Re: Extracting elements over multiple lists? Chris Angelico <rosuav@gmail.com> - 2011-11-16 09:54 +1100
    Re: Extracting elements over multiple lists? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-11-07 19:06 +0100

csiph-web