https://github.com/python/cpython/commit/37b5cc4b793960d30938ac2e2fa14d8c58bc329a
commit: 37b5cc4b793960d30938ac2e2fa14d8c58bc329a
branch: main
author: Shanzhi Chen <[email protected]>
committer: StanFromIreland <[email protected]>
date: 2026-11-09T14:17:16Z
summary:
gh-161467: Enable `__attribute__((hot))` for Clang (#161468)
files:
A Misc/NEWS.d/next/Build/2026-11-06-09-16-30.gh-issue-161467.oSuzx_.rst
M Include/pyport.h
diff --git a/Include/pyport.h b/Include/pyport.h
index c6cc47f7a14103..718a9b50bae103 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -306,16 +306,15 @@ extern "C" {
* Usage:
* int _Py_HOT_FUNCTION x(void) { return 3; }
*
- * Issue #28618: This attribute must not be abused, otherwise it can have a
+ * Issue gh-72804: This attribute must not be abused, otherwise it can have a
* negative effect on performance. Only the functions were Python spend most of
* its time must use it. Use a profiler when running performance benchmark
* suite to find these functions.
*/
-#if defined(__GNUC__) \
- && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
-#define _Py_HOT_FUNCTION __attribute__((hot))
+#if _Py__has_attribute(hot)
+# define _Py_HOT_FUNCTION __attribute__((hot))
#else
-#define _Py_HOT_FUNCTION
+# define _Py_HOT_FUNCTION
#endif
// Ask the compiler to always inline a static inline function. The compiler can
diff --git
a/Misc/NEWS.d/next/Build/2026-11-06-09-16-30.gh-issue-161467.oSuzx_.rst
b/Misc/NEWS.d/next/Build/2026-11-06-09-16-30.gh-issue-161467.oSuzx_.rst
new file mode 100644
index 00000000000000..ae34c60e989ead
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-11-06-09-16-30.gh-issue-161467.oSuzx_.rst
@@ -0,0 +1 @@
+Enable the use of ``__attribute__((hot))`` when building CPython with Clang
and other compilers that support it.
_______________________________________________
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]