This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author corona10
Recipients corona10, pablogsal, vstinner
Date 2021-05-05.12:10:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1620216658.8.0.390756797773.issue44049@roundup.psfhosted.org>
In-reply-to
Content
I had a chance to read Python/suggestion.c and I can notice that we use the static declared size of the array.

Since we live in the C99 era and the CPython codebase already uses C99(struct initialization is a good example), how about using the C99 feature if possible.

We should care about stack overflow from the big input but with the expected very small input size it will be okay to use.

-    static size_t buffer[MAX_STRING_SIZE];
-
     // Both strings are the same (by identity)
     if (a == b) {
         return 0;
@@ -68,6 +66,8 @@ levenshtein_distance(const char *a, size_t a_size,
         size_t t_size = a_size; a_size = b_size; b_size = t_size;
     }

+    size_t buffer[a_size];
+
     // quick fail when a match is impossible.
     if ((b_size - a_size) * MOVE_COST > max_cost) {
         return max_cost + 1
History
Date User Action Args
2021-05-05 12:10:58corona10setrecipients: + corona10, vstinner, pablogsal
2021-05-05 12:10:58corona10setmessageid: <1620216658.8.0.390756797773.issue44049@roundup.psfhosted.org>
2021-05-05 12:10:58corona10linkissue44049 messages
2021-05-05 12:10:58corona10create