Lie Ryan a écrit :
On 03/17/2010 08:12 PM, Bruno Desthuilliers wrote:
Patrick Maupin a écrit :
On Mar 16, 1:59 pm, Jason Tackaberry <t...@urandom.ca> wrote:
Why not create the bound methods at instantiation time, rather than
using the descriptor protocol which has the overhead of creating a new
bound method each time the method attribute is accessed?
Well, for one thing, Python classes are open.  They can be added to at
any time.  For another thing, you might not ever use most of the
methods of an instance, so it would be a huge waste to create those.
A possible optimization would be a simple memoization on first access.

But what if, for example, one uses some descriptor/metaclass magic to
make it so that each subsequent access to the attribute returns a method
bound to different objects?

Well, that's the whole problem with dynamism vs optimization...
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to