New submission from Dong-hee Na <donghee...@python.org>:
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 ---------- messages: 393006 nosy: corona10, pablogsal, vstinner priority: normal severity: normal status: open title: Use C99 Variable-length array if possible type: enhancement versions: Python 3.11 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44049> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com