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.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to