On Tue, Nov 11, 2014 at 5:43 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote:
> On Sat, Nov 8, 2014 at 3:31 PM, Gregory Ewing > <greg.ew...@canterbury.ac.nz> wrote: > > (BTW, I'm actually surprised that this technique makes c callable. > > There must be more going on that just "look up __call__ in the class > > object", because evaluating C.__call__ just returns the descriptor > > and doesn't invoking the descriptor mechanism.) > > But of course it doesn't just lookup C.__call__, because it has to > bind the method to the instance before calling it, which means > invoking the descriptor protocol. The actual lookup is more like: > > type(a).__dict__['__call__'].__get__(a, type(a)) > -- > https://mail.python.org/mailman/listinfo/python-list > As a reference, I recently found a blog post related to that: http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/ (the Slots part comments on that). It does seem a bit counter-intuitive that this happens the way it does though, so, can someone from python-dev give some background of why that's the way it is? i.e.: instead of the approach which would seem simpler which would do getattr(a, '__call__') instead of type(a).__dict__['__call__'].__get__(a, type(a)) -- it seems to me it's mostly because of historical reasons, but I'm really curious why is it so (and if maybe it's something which python-dev would consider worth changing in the future -- not sure how much could break because of that though). Thanks and Best Regards, Fabio
-- https://mail.python.org/mailman/listinfo/python-list