Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2423
| References | <4D95EA23.10802@aim.com> <in5gel$5cd$1@dough.gmane.org> |
|---|---|
| Date | 2011-04-02 13:21 +1100 |
| Subject | Re: The Magick of __call__ (Or, Digging Deeper Than I Ought To) |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.114.1301710868.2990.python-list@python.org> (permalink) |
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
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