From adcb6a6055c7fe6e02621f66945be237b42e945a Mon Sep 17 00:00:00 2001 From: Michael Droettboom <mdboom@gmail.com> Date: Thu, 5 May 2022 23:59:45 -0400 Subject: [PATCH] gh-92356: Fix regression in ctypes function call overhead (#92357) 38f331d introduced a delayed initialization routine to set up ctypes formattable (`_ctypes_init_fielddesc`), but inadvertently removed setting the `initialization` flag to 1 to avoid initting each time. --- .../next/Library/2022-05-05-19-25-09.gh-issue-92356.uvxWdu.rst | 1 + Modules/_ctypes/cfield.c | 1 + 2 files changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2022-05-05-19-25-09.gh-issue-92356.uvxWdu.rst diff --git a/Misc/NEWS.d/next/Library/2022-05-05-19-25-09.gh-issue-92356.uvxWdu.rst b/Misc/NEWS.d/next/Library/2022-05-05-19-25-09.gh-issue-92356.uvxWdu.rst new file mode 100644 index 00000000000..9c9566e5b9d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-05-19-25-09.gh-issue-92356.uvxWdu.rst @@ -0,0 +1 @@ +Fixed a performance regression in ctypes function calls. diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 23c11c98b2a..c7234fbb18a 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1602,6 +1602,7 @@ _ctypes_get_fielddesc(const char *fmt) struct fielddesc *table = formattable; if (!initialized) { + initialized = 1; _ctypes_init_fielddesc(); } -- GitLab