Couldn't you use self.review reducing this loop to O(1)? (Does the url contain <review_id>?) Alternatively, if you use a cached 'review' object around here somewhere, you can use review._reviews[review_id].