Skip to content

Commit 281eec8

Browse files
authored
Merge pull request #4147 from jcassette/query-perf
Use short-circuit evaluation in AndQuery and OrQuery (fix #4145)
2 parents b7d0ddf + 5e6be0d commit 281eec8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

beets/dbcore/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def clause(self):
443443
return self.clause_with_joiner('and')
444444

445445
def match(self, item):
446-
return all([q.match(item) for q in self.subqueries])
446+
return all(q.match(item) for q in self.subqueries)
447447

448448

449449
class OrQuery(MutableCollectionQuery):
@@ -453,7 +453,7 @@ def clause(self):
453453
return self.clause_with_joiner('or')
454454

455455
def match(self, item):
456-
return any([q.match(item) for q in self.subqueries])
456+
return any(q.match(item) for q in self.subqueries)
457457

458458

459459
class NotQuery(Query):

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ Bug fixes:
7474
* :doc:`/dev/library`: Use slow queries for flexible attributes in aunique.
7575
:bug:`2678` :bug:`3553`
7676

77+
* :doc:`/reference/query`: Use short-circuit evaluation in AndQuery and OrQuery
78+
:bug:`4145`
79+
7780
1.5.0 (August 19, 2021)
7881
-----------------------
7982

0 commit comments

Comments
 (0)