https://github.com/python/cpython/commit/95d6e0b2830c8e6bfd861042f6df6343891d5843
commit: 95d6e0b2830c8e6bfd861042f6df6343891d5843
branch: main
author: Chris Eibl <[email protected]>
committer: zooba <[email protected]>
date: 2025-08-25T21:59:52+01:00
summary:

GH-131033: Enable the optimizing macros UNLIKELY and LIKELY for Clang 
(GH-131019)

This includes clang-cl on Windows, which does not define the GCC version that 
was previously being checked.

files:
M Objects/obmalloc.c

diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index deb7fd957e57dd..2b95ebbf8e5ac0 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -1523,9 +1523,9 @@ PyObject_Free(void *ptr)
 }
 
 
-/* If we're using GCC, use __builtin_expect() to reduce overhead of
+/* Use __builtin_expect() where available to reduce overhead of
    the valgrind checks */
-#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
+#if (defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 2))) && 
defined(__OPTIMIZE__)
 #  define UNLIKELY(value) __builtin_expect((value), 0)
 #  define LIKELY(value) __builtin_expect((value), 1)
 #else

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to