Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
expensive properties should really be methods #470
Computed properties are great for keeping code clean. Small computations or remapping's of values (e.g.
As an example, say we have the following:
n_x = mesh.vertex_normals n_y = mesh.vertex_normals n_z = mesh.vertex_normals
This doesn't look like a particularly troubling block of code, but in reality
vn = mesh.vertex_normals n_x = vn n_y = vn n_z = vn
The issue is that the user has no way of knowing that this is an expensive operation that should be cached in such a manner. There is a simple change that makes the behavior much more apparent - just make
vn = mesh.vertex_normals() n_x = vn n_y = vn n_z = vn
Now the user would think twice about calling the method needlessly many times.
This PR goes through the shape module and changes a number of properties to methods. The rule I've tried to follow is -
The ones I've done here are: