Skip to content

Commit de0aaba

Browse files
Use math.perm instead of math.comb
1 parent 98a04a8 commit de0aaba

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/django_ltree/paths.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,16 @@ def __next__(self):
3030

3131
@staticmethod
3232
def guess_the_label_size(path_size: int, combination_size: int) -> int:
33-
# The theoritical limit for this at the time of writing is 2_538_557_185_841_324_496 (python 3.12.2)
3433
calculated_path_size = -1 # -1 is here for 0th index items
3534
# The theoritical limit for this at the time of writing is 32 (python 3.12.2)
3635
label_size = 0
3736

38-
# THIS IS AN VERY IMPORTANT CHECK
3937
last = 0
4038

4139
while True:
42-
possible_cominations = math.comb(combination_size, label_size)
40+
possible_cominations = math.perm(combination_size, label_size)
4341
if last > possible_cominations:
44-
raise ValueError("We approached the limit of `math.comb`")
42+
raise ValueError("There is error in the input value")
4543

4644
last = possible_cominations
4745
calculated_path_size += possible_cominations

0 commit comments

Comments
 (0)