On Fri, May 15, 2015 at 9:00 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Fri, May 15, 2015 at 6:43 AM, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: >> How much time would it save? Probably very little. After all, unless the >> method call itself did bugger-all work, the time to create the method >> object is probably insignificant. But it's a possible optimization. > > An interesting alternative (if it's not already being done) might be > to maintain a limited free-list of method objects, removing the need > to allocate memory for one before filling it in with data.
Looks like it is already being done: https://hg.python.org/cpython/file/e7c7431f91b2/Objects/methodobject.c#l7 -- https://mail.python.org/mailman/listinfo/python-list