Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Lost in descriptor land Date: Sat, 2 Jul 2016 17:06:47 -0600 Lines: 21 Message-ID: References: <5a7b6360-5b9b-465c-8401-9a0079048931@googlegroups.com> <7b72a3a0-f0c0-429a-b383-5c3dbfdedba5@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de Fd0rqzeHGNaCz+TiEIZs5wgbwdtJVqYtsmQ0/E0UMkrg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'friday,': 0.07; 'definition,': 0.09; 'descriptor': 0.09; '2016': 0.16; 'descriptors,': 0.16; 'instantiate': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'say,': 0.18; "shouldn't": 0.18; 'saying': 0.22; 'lawrence': 0.22; 'am,': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'define': 0.27; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; '(it': 0.29; 'classes': 0.30; 'certainly': 0.30; 'checks': 0.30; 'saves': 0.30; 'guess': 0.31; "can't": 0.32; 'class': 0.33; 'instances': 0.33; 'received:google.com': 0.35; 'done': 0.35; 'instance': 0.35; 'but': 0.36; 'instead': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'rather': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'jul': 0.72; 'state.': 0.72; 'to:name:python': 0.84; 'utc+5:30,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=6RNoCGnIvV4mz+kOt+ZZvN0GBmJIvMC/Kw2U3Y390Fs=; b=vIl5Hiz5QMTwXp5G2+L5fu9Ibm7oco+79kglud6ngzjkmUv8LBrzs95Wr88L8E3NHE Is8KFsc9H01qbn4o0Iq8KDjf+/WW0Izy7yuywnVw+ptb8zulcha9kfeCXQ/J38Kdk1iV tSkPZ3/o/Zjz6QELD1Q8iD7xMd5WajOWj4l+2Bp3xYLU7p10ZtlqDYYlP/RlrguUYD4F f7zgW1+TUKNpNcIQzElcKP6WXEVSijRLNSB8qUV4gyh7cgYjSkKEHoA/0pKRQ0xtjhHr b7IWHz5kzbpefM4KRvBSS+hl82uNAeuTr3UdiV+6ZVLl4d3u4yUUtoZDIXpp4JZIYXq+ IbdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=6RNoCGnIvV4mz+kOt+ZZvN0GBmJIvMC/Kw2U3Y390Fs=; b=U+RlLdDPBeP4YQKqu1WYTpssLoMNQ6IYS0qcwcJvXS7J4FkBl0ahLKIHfdMZ6djUQy jK6E8jqZOZqpjCM4kNL7fA6yas/vU0p8JFIzjpjnQp732Jyxmd/sjKowv1EPgLxjVmvy i+oMtl0j4vZ1kW5L2BvpS7mDaEmTThpqj0Ro8sBoNOC+3O+Ksb5/lBTiS/8B1vT7cvXd F+OO6CfjOTnYmWVKMXFUO63mjXB6pFAmZ62akPpKsRpBL1Hsh5pijbI+KVt1sLJ+p1Dc 4rznl+K+8i5HiW6joOGo9nIFvuwzjKNo+eaDk09zXSVgKiYe4RWR4FK6ejIaUrd6nGI6 cpRA== X-Gm-Message-State: ALyK8tKif7prHEt28evIDtpkTKXwctsiU4o9nRHeYVajaIkAIy6wcrqQy0VfLlTu5OgYdIUJkGeD44Y7J1PI5w== X-Received: by 10.202.244.72 with SMTP id s69mr2659778oih.24.1467500846838; Sat, 02 Jul 2016 16:07:26 -0700 (PDT) In-Reply-To: <7b72a3a0-f0c0-429a-b383-5c3dbfdedba5@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <5a7b6360-5b9b-465c-8401-9a0079048931@googlegroups.com> <7b72a3a0-f0c0-429a-b383-5c3dbfdedba5@googlegroups.com> Xref: csiph.com comp.lang.python:110965 On Sat, Jul 2, 2016 at 5:32 AM, Ankush Thakur w= rote: > On Friday, July 1, 2016 at 9:13:19 AM UTC+5:30, Lawrence D=E2=80=99Olivei= ro wrote: >> >> > Shouldn't we be instead using self.celcius in, say, __init__() and the= n >> > 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 c= lass-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).