to pass self or not to pass self
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Wed Mar 17 05:12:54 EDT 2010
Patrick Maupin a écrit :
> On Mar 16, 1:59 pm, Jason Tackaberry <t... at 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.
More information about the Python-list
mailing list