[Python-checkins] bpo-32436: Make PyContextVar_Get a little bit faster (#5350)

Yury Selivanov webhook-mailer at python.org
Fri Jan 26 17:24:55 EST 2018


https://github.com/python/cpython/commit/226e50049da43097d89e9e99f9c55f212d1f7bd5
commit: 226e50049da43097d89e9e99f9c55f212d1f7bd5
branch: master
author: Yury Selivanov <yury at magic.io>
committer: GitHub <noreply at github.com>
date: 2018-01-26T17:24:52-05:00
summary:

bpo-32436: Make PyContextVar_Get a little bit faster (#5350)

Since context.c is compiled with Py_BUILD_CORE, using a macro
will result in a slightly more optimal code.

files:
M Python/context.c

diff --git a/Python/context.c b/Python/context.c
index d90ed25c4d4..3928e94d064 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -145,7 +145,8 @@ PyContextVar_Get(PyContextVar *var, PyObject *def, PyObject **val)
 {
     assert(PyContextVar_CheckExact(var));
 
-    PyThreadState *ts = PyThreadState_Get();
+    PyThreadState *ts = PyThreadState_GET();
+    assert(ts != NULL);
     if (ts->context == NULL) {
         goto not_found;
     }



More information about the Python-checkins mailing list