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


Groups > comp.lang.python > #67868

Re: Reference

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Reference
Date 2014-03-06 05:33 +1100
References (11 earlier) <164d209c-ba5e-449f-bc25-c27ebfb1fc0f@googlegroups.com> <5316b0dc$0$2923$c3e8da3$76491128@news.astraweb.com> <55d6a455-1856-4fd6-ac4b-c277ff7e2bd1@googlegroups.com> <mailman.7793.1394000462.18130.python-list@python.org> <60b9aaba-7991-415d-b3c6-dc18c5539502@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.7830.1394044452.18130.python-list@python.org> (permalink)

Show all headers | View raw


Rustom Mody <rustompmody@gmail.com> writes:

> On Wednesday, March 5, 2014 11:50:46 AM UTC+5:30, Ben Finney wrote:
> > So, what machine represenatation is leaked?
>
> > I'll re-iterate that "memory location of the object" isn't a valid
> > response. There is no necessary relation between the memory location of
> > the object referenced by "foo" and the return value of 'id(foo)'.
>
> ... however you are both disagreeing with me and also saying Ive not
> given the answer and further disagreeing with the python standard,
> which I quote:
>
> Every object has an identity, a type and a value. An object's identity
> never changes once it has been created; you may think of it as the
> object's address in memory. The 'is' operator compares the identity of
> two objects; the id() function returns an integer representing its
> identity (currently implemented as its address).
>
> from http://docs.python.org/2/reference/datamodel.html

Right. None of which constitutes a leaking abstraction. I'll repeat the
point: the abstraction does not leak if the user of that abstraction has
no need to deal with what lies beneath it.

In other words: A helpful “you may think of it as the object's address
in memory” does not constitute a leaky abstraction, because it would be
just as correct to say “you may think of it as a snowflake”.

There is no need for the user of the abstraction “object identity” to
know anything about the object's location in memory (nor of snowflakes),
nor ever to think about it when using the abstraction. You may, as the
documentation suggests, think of it that way; but you may also think of
it as anything else which agrees with the abstraction.

The clause about “object's location in memory” is not normative, does
not matter for using the abstraction, and is not part of the definition.
It literally does not matter for the purpose of using the abstraction,
so there's no leak.

In fact, in the current Python documentation the description has changed:

    Every object has an identity, a type and a value. An object’s
    identity never changes once it has been created; you may think of it
    as the object’s address in memory. The ‘is‘ operator compares the
    identity of two objects; the id() function returns an integer
    representing its identity.

    CPython implementation detail: For CPython, id(x) is the memory
    address where x is stored.

    <URL:http://docs.python.org/3/reference/datamodel.html>

So it's now even clearer that “memory address where the object is
stored” is *not* part of the abstraction, is *not* guaranteed to be what
‘id(foo)’ returns, and is an implementation detail of one particular
implementation, that can be ignored.

The abstraction “object identity” behaves exactly as the documentation
says it does, in the absence of any “object address in memory” concept,
and this is not undermined by suggestions that the reader may already
have a concept in mind which can help them to imagine the abstraction.

> So when you say
> > I'll re-iterate that "memory location of the object" isn't a valid
> > response. 
>
> well... all I can say is I dont know what to say :-)

I'd encourage you to read the documentation for comprehension. Not every
word in a discussion of a concept must be normative.

I'd also encourage you to report a bug, suggesting a documentation
improvement if you have been misled by (the latest version of) the
language reference.

-- 
 \        “Of course, everybody says they're for peace. Hitler was for |
  `\      peace. Everybody is for peace. The question is: what kind of |
_o__)                                peace?” —Noam Chomsky, 1984-05-14 |
Ben Finney

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


Thread

Reference "ast" <nomail@invalid.com> - 2014-03-03 10:42 +0100
  Object identity (was: Reference) Ben Finney <ben+python@benfinney.id.au> - 2014-03-03 21:00 +1100
    Re: Object identity (was: Reference) "ast" <nomail@invalid.com> - 2014-03-03 11:21 +0100
  Re: Reference "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-03 05:09 -0800
  Re: Reference Grant Edwards <invalid@invalid.invalid> - 2014-03-03 14:29 +0000
  Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-03 07:52 -0800
    Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 08:10 +1100
    Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-03 15:24 -0600
    Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 08:31 +1100
    Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-03 21:35 +0000
      Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 00:07 +0200
        Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 09:18 +1100
          Re: Reference Alister <alister.ware@ntlworld.com> - 2014-03-04 11:10 +0000
            Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 11:48 +0000
              Re: Reference "Rhodri James" <rhodri@wildebst.org.uk> - 2014-03-05 00:25 +0000
    Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-03 15:51 -0600
    Re: Reference Jerry Hill <malaclypse2@gmail.com> - 2014-03-03 17:02 -0500
      Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-04 00:22 +0200
        Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-04 09:27 +1100
        Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 09:33 +1100
        Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-04 04:52 +0000
          Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-04 16:24 +1100
            Re: Reference "Rhodri James" <rhodri@wildebst.org.uk> - 2014-03-05 01:08 +0000
              Re: Reference Roy Smith <roy@panix.com> - 2014-03-04 21:09 -0500
                Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 19:36 -0800
                Re: Reference Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-04 21:08 -0700
                Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 20:31 -0800
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 15:32 +1100
                Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 20:47 -0800
                Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-05 05:06 +0000
                Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 21:47 -0800
                Re: Reference alex23 <wuwei23@gmail.com> - 2014-03-05 16:01 +1000
                Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 22:10 -0800
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 17:22 +1100
                Re: Reference alex23 <wuwei23@gmail.com> - 2014-03-05 16:28 +1000
                Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 12:24 +0000
                Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 12:21 +0000
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 17:20 +1100
                Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-05 09:40 -0800
                Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-05 12:12 -0600
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 05:33 +1100
                Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-05 18:19 +0000
                Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 22:23 +0200
                Re: Reference Grant Edwards <invalid@invalid.invalid> - 2014-03-05 20:31 +0000
                Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 22:46 +0200
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 08:07 +1100
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 08:10 +1100
                Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 21:34 +0000
                Re: Reference Terry Reedy <tjreedy@udel.edu> - 2014-03-05 18:00 -0500
                Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-06 03:01 +0000
                Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 22:03 -0800
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 17:26 +1100
                Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 17:32 +1100
                Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-05 08:24 -0600
                Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-05 18:29 +0000
                Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 22:34 +0200
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 08:01 +1100
                Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 23:14 +0200
                Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-06 08:26 +1100
                Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 23:50 +0200
                Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-06 00:35 +0000
                Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-06 11:50 +1100
                Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-06 17:46 +0000
                Re: Reference Tim Chase <python.list@tim.thechases.com> - 2014-03-05 15:33 -0600
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 08:37 +1100
                Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-06 02:52 +0200
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-06 12:05 +1100
                Re: Reference alex23 <wuwei23@gmail.com> - 2014-03-06 12:12 +1000
                Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 21:46 +0000
                Re: Reference Marko Rauhamaa <marko@pacujo.net> - 2014-03-05 08:23 +0200
                Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 22:33 -0800
                Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-05 17:40 +1100
                Re: Reference Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-05 12:35 +0000
                Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 23:45 +1100
          Re: Reference Jerry Hill <malaclypse2@gmail.com> - 2014-03-04 10:19 -0500
            Re: Reference Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-04 15:42 +0000
              Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 03:02 +1100
                Re: Reference Roy Smith <roy@panix.com> - 2014-03-04 11:14 -0500
              Re: Reference MRAB <python@mrabarnett.plus.com> - 2014-03-04 17:12 +0000
            Re: Reference Rustom Mody <rustompmody@gmail.com> - 2014-03-04 08:24 -0800
          Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 02:25 +1100
          Re: Reference Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2014-03-05 14:37 +0100
      Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-04 03:59 +0000
    Re: Reference Ben Finney <ben+python@benfinney.id.au> - 2014-03-04 09:17 +1100
      Re: Reference Roy Smith <roy@panix.com> - 2014-03-03 18:02 -0500
        Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-04 10:09 +1100
        Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-04 04:38 +0000
  Re: Reference Terry Reedy <tjreedy@udel.edu> - 2014-03-03 13:48 -0500
    Re: Reference Steven D'Aprano <steve@pearwood.info> - 2014-03-04 03:45 +0000
    Re: Reference Alexander Blinne <news@blinne.net> - 2014-03-04 13:55 +0100
      Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 01:06 +1100
        Re: Reference Alexander Blinne <news@blinne.net> - 2014-03-04 22:53 +0100
          Re: Reference Chris Angelico <rosuav@gmail.com> - 2014-03-05 09:01 +1100

csiph-web