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


Groups > comp.lang.python > #2423 > unrolled thread

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

Started byChris Angelico <rosuav@gmail.com>
First post2011-04-02 13:21 +1100
Last post2011-04-02 13:21 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromChris Angelico <rosuav@gmail.com>
Date2011-04-02 13:21 +1100
SubjectRe: The Magick of __call__ (Or, Digging Deeper Than I Ought To)
Message-ID<mailman.114.1301710868.2990.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web