[Python-Dev] Summary of "dynamic attribute access" discussion

Larry Hastings larry at hastings.org
Tue Feb 13 22:38:42 CET 2007


Larry Hastings wrote:
> I just duplicated this test on all the .py files in the Lib directory 
> tree of a freshly updated 2.5 trunk.
Whoops!  Sorry, bungled it again.  I counted definitions of __*attr__ too.

This time I used "fgrep -w getattr | fgrep 'getattr('" to cull.  The 
corrected results:
    9    27   611 dels
  488  2637 38947 gets
  120   539  8644 sets
  617  3203 48202 total

So 617 lines out of 471,821 lines called *attr() functions, or 0.13%.  
In other words *attr() functions are used on 1 out of every 764 lines.


/larry/


More information about the Python-Dev mailing list