Currently, the version.previous attribute is calling VersionObjectFetcher.previous
Which runs: self.previous_query(obj).first()
Because it is using .first() - a query is running every time.
It would be a nice developer experience to cache this so it does not call multiple queries.
Currently I need to do:
current = ...
previous = current.previous
And then pass it all around in my functions to avoid performance issues.
It would make my code a lot simpler if the previous property cached the value so I did not need to save it in my own separate variable
Currently, the version.previous attribute is calling
VersionObjectFetcher.previous
Which runs:self.previous_query(obj).first()
Because it is using
.first()
- a query is running every time.It would be a nice developer experience to cache this so it does not call multiple queries.
Currently I need to do:
And then pass it all around in my functions to avoid performance issues. It would make my code a lot simpler if the
previous
property cached the value so I did not need to save it in my own separate variable