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


Groups > comp.lang.python > #110965

Re: Lost in descriptor land

From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Lost in descriptor land
Date 2016-07-02 17:06 -0600
Message-ID <mailman.30.1467500855.2295.python-list@python.org> (permalink)
References <b9c69ca0-a338-41ec-bfa5-b14510e2cb8f@googlegroups.com> <5a7b6360-5b9b-465c-8401-9a0079048931@googlegroups.com> <7b72a3a0-f0c0-429a-b383-5c3dbfdedba5@googlegroups.com> <CALwzidk9AJa0m0086_xKcYearCv34NK8xQ2Q=1SMZv7WbM2yRA@mail.gmail.com>

Show all headers | View raw


On Sat, Jul 2, 2016 at 5:32 AM, Ankush Thakur <ankush.thakur53@gmail.com> wrote:
> On Friday, July 1, 2016 at 9:13:19 AM UTC+5:30, Lawrence D’Oliveiro wrote:
>>
>> > Shouldn't we be instead using self.celcius in, say, __init__() and then
>> > everything will work fine?
>>
>> I guess it might. But this way, using descriptors, all the setup is done once at class definition, rather then every time in class instantiation.
>
> So you're saying the (sole) reason to instantiate descriptor classes at class-level is performance?

Performance might be part of it (it also saves some checks when
looking up attributes), but in my opinion a big reason for it is
separation of responsibilities. Classes define object behavior;
instances contain object state. For example, you can't define a method
on an instance (though you can certainly store a function there and
call it).

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


Thread

Lost in descriptor land Ankush Thakur <ankush.thakur53@gmail.com> - 2016-06-30 18:06 -0700
  Re: Lost in descriptor land Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-30 19:36 -0600
    Re: Lost in descriptor land Ankush Thakur <ankush.thakur53@gmail.com> - 2016-07-02 04:27 -0700
  Re: Lost in descriptor land Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-30 20:33 -0700
    Re: Lost in descriptor land Ankush Thakur <ankush.thakur53@gmail.com> - 2016-07-02 04:30 -0700
      Re: Lost in descriptor land Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-02 18:02 -0700
        Re: Lost in descriptor land Ankush Thakur <ankush.thakur53@gmail.com> - 2016-07-03 06:29 -0700
  Re: Lost in descriptor land Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-30 20:43 -0700
    Re: Lost in descriptor land Ankush Thakur <ankush.thakur53@gmail.com> - 2016-07-02 04:32 -0700
      Re: Lost in descriptor land Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-02 17:06 -0600
        Re: Lost in descriptor land Ankush Thakur <ankush.thakur53@gmail.com> - 2016-07-03 06:27 -0700
        Re: Lost in descriptor land Steven D'Aprano <steve@pearwood.info> - 2016-07-04 01:32 +1000
          Re: Lost in descriptor land eryk sun <eryksun@gmail.com> - 2016-07-03 23:59 +0000
            Re: Lost in descriptor land Steven D'Aprano <steve@pearwood.info> - 2016-07-04 11:56 +1000

csiph-web