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


Groups > comp.lang.python > #2423

Re: The Magick of __call__ (Or, Digging Deeper Than I Ought To)

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'instance,': 0.05; 'terry': 0.07; 'wrapper': 0.07; 'bind': 0.09; 'dict': 0.09; 'says,': 0.09; 'stuff!': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'dictionary,': 0.16; 'indefinitely': 0.16; 'instance:': 0.16; 'methods,': 0.16; 'reedy': 0.16; 'method.': 0.19; 'header:In-Reply-To:1': 0.22; 'itself.': 0.22; 'objects': 0.24; 'creating': 0.26; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; 'thanks': 0.29; 'sat,': 0.29; 'bound': 0.29; 'it.': 0.31; 'to:addr:python-list': 0.32; 'created': 0.33; 'thinking': 0.33; 'lines': 0.34; 'reference': 0.34; 'normally': 0.35; 'too': 0.36; 'some': 0.37; 'case': 0.37; 'self': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'pretty': 0.38; 'unless': 0.38; 'to:addr:python.org': 0.39; 'subject: (': 0.39; 'received:209': 0.39; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'subject': 0.61; '2011': 0.62; 'special': 0.66; 'details.': 0.67; 'subject:The': 0.69; 'kept': 0.73; 'loves': 0.73; '__call__': 0.84; 'common,': 0.84; 'received:209.85.210.174': 0.84; 'received :mail-iy0-f174.google.com': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=w8Y+lmJAfYL+dU+DhvSzLcyPomr19JHn2vUNmU7luu8=; b=QttPSitWHEJ3rUbzqBiJO4z5rAPbIb/h1LZ0fPzbdJ1wGwHznqcrf/vTGkpNzoZz+S 41hNT2BfvvUsEVPlKughTEsiJ7PQf8sbCRlA6rRMPAFm7pJTKBrQG18BSevo6NdoE8Ou 0H57CNM+NKSIIh27r1V5wcdtBgFZ1gSjwQlFE=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=WrULZem5MVUJO4OThjIgN8qN1z5c9RCcRD2JM0tKc8pX9m7yizJSBpmiaV0XUluZhM 0a3uNrnO0cRcSvWmhLvbuSaLTZ14GWz6WpxLXb4nbH+BP67L9fTiOCjY8r9EHUc42FlR REY6sK5VVk3BniCzqX0ohQ5pMqRzKsSinoKio=
MIME-Version 1.0
In-Reply-To <in5gel$5cd$1@dough.gmane.org>
References <4D95EA23.10802@aim.com> <in5gel$5cd$1@dough.gmane.org>
Date Sat, 2 Apr 2011 13:21:06 +1100
Subject Re: The Magick of __call__ (Or, Digging Deeper Than I Ought To)
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.114.1301710868.2990.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 82.94.164.166
X-Trace 1301710869 news.xs4all.nl 81484 [::ffff:82.94.164.166]:39663
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2423

Show key headers only | View raw


Thanks for those explanations! As Corey's original subject says, this
IS digging pretty deep into implementation details. My geekly side
loves that though!

On Sat, Apr 2, 2011 at 8:35 AM, Terry Reedy <tjreedy@udel.edu> wrote:
> Every time a method is accessed through an instance, a new wrapper is
> created. Why? 1. If you want to reuse a bound methods, just bind it to a
> name or something and reuse it. 2. To automatically keep it for possible
> reuse, which normally is not too common, it wold have to be kept in some
> hidden dict which would grow indefinitely unless pruned occasionally.

What I was thinking was something along the lines of a loop-back
reference in the wrapper itself. So for instance:

Foo.__call__ = wrapper(Foo)

The wrapper would be created with a __call__ method of itself:
self.__call__ = self

That would not require a dictionary, it's just a special case of
creating the __call__ method. Since, apparently, we can "go infinite"
with the __call__ dereferencing, these objects must be created when
referenced?

Fascinating stuff!

Chris Angelico

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


Thread

Re: The Magick of __call__ (Or, Digging Deeper Than I Ought To) Chris Angelico <rosuav@gmail.com> - 2011-04-02 13:21 +1100

csiph-web