why is this so slow?

Lowell Kirsh lkirsh at cs.ubc.ca
Thu Sep 2 00:00:45 EDT 2004


I created the following class (I know it's a dirty hack) so I could do 
foo.bar instead of using a dictionary and having to type foo['bar'] :

     class DefaultAttr(object):
         def __getattribute__(self, attr):
             if not hasattr(self, attr):
                 return ''
             return object.__getattribute__(self,attr)

but its use is totally slowing down my program. Why is it so slow and is 
there a better way?

Lowell



More information about the Python-list mailing list