[Python-checkins] gh-92356: Fix regression in ctypes function call overhead (#92357)

JelleZijlstra webhook-mailer at python.org
Thu May 5 23:59:55 EDT 2022


https://github.com/python/cpython/commit/adcb6a6055c7fe6e02621f66945be237b42e945a
commit: adcb6a6055c7fe6e02621f66945be237b42e945a
branch: main
author: Michael Droettboom <mdboom at gmail.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-05-05T20:59:45-07:00
summary:

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.

files:
A Misc/NEWS.d/next/Library/2022-05-05-19-25-09.gh-issue-92356.uvxWdu.rst
M Modules/_ctypes/cfield.c

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 0000000000000..9c9566e5b9d71
--- /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 23c11c98b2afc..c7234fbb18a0f 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();
     }
 



More information about the Python-checkins mailing list