Skip to content

Commit

Permalink
Replace expensive count() with cheap exists() (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuky authored Jun 3, 2024
1 parent 01ebed3 commit 1899c19
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion model_bakery/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _mapping( # noqa: C901
m = finder.get_model(self._model)
else:
m = self._model
if k not in self._iterator_backups or m.objects.count() == 0:
if k not in self._iterator_backups or not m.objects.exists():
self._iterator_backups[k] = itertools.tee(
self._iterator_backups.get(k, [v])[0]
)
Expand Down

0 comments on commit 1899c19

Please sign in to comment.