[IMP] website_forum: perf - replace any by in
Usinf of any seems not efficient in this case
> timeit.timeit('any(7 == o for o in [1,3,5,7,9,12])', number=10000000)
6.556934245978482
> timeit.timeit('7 in set([1,3,5,7,9,12])', number=10000000)
2.78867393406108
> timeit.timeit('7 in [1,3,5,7,9,12]', number=10000000)
0.534781630965881
This commit is contained in:
@@ -401,7 +401,7 @@ class Post(models.Model):
|
||||
|
||||
def _get_uid_has_answered(self):
|
||||
for post in self:
|
||||
post.uid_has_answered = any(answer.create_uid.id == post._uid for answer in post.child_ids)
|
||||
post.uid_has_answered = post._uid in post.child_ids.create_uid.ids
|
||||
|
||||
@api.depends('child_ids.is_correct')
|
||||
def _get_has_validated_answer(self):
|
||||
|
||||
Reference in New Issue
Block a user