Opened 5 years ago
Closed 5 years ago
#31706 closed Cleanup/optimization (fixed)
Removed unnecessary getattr() call in FileDescriptor.__get__().
Reported by: | Sultan | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
To retrieve a deferred model attributes, the __get__
method is called twice. This is because it uses the getattr()
function, which in turn causes the __get__
method to be called again.
To prevent this unnecessary call, we can simply delete it (since at that moment the instance dict already contains the reloaded value). This reduces the number of method calls.
Note:
See TracTickets
for help on using tickets.
PR