3 ms·
> hasattr() also is not faster than getattr() since it goes through the exactly same lookup process and then throws away the result In practice this only matte
by true_religion 11y ago
> hasattr() also is not faster than getattr() since it goes through the exactly same lookup process and then throws away the result
In practice this only matters if you have a property. If you use hasattr to find a method within an object, it will not invoke the method while checking for existence.