Skip to content

Commit

Permalink
refactor: replace multiple == checks with in
Browse files Browse the repository at this point in the history
To check if a variable is equal to one of many values, combine the values into a tuple and check if the variable is contained `in` it instead of checking for equality against each of the values.
This is faster, less verbose, and more readable.
  • Loading branch information
deepsource-autofix[bot] authored Jun 3, 2024
1 parent cab3713 commit 1224789
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def is_even(x):
return x % 2 == 0

def is_prime(x):
if x == 0 or x == 1:
if x in (0, 1):
return False

for i in range(2, x):
Expand Down

0 comments on commit 1224789

Please sign in to comment.