diff options
author | Brett Cannon <brett@python.org> | 2016-09-07 18:16:41 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2016-09-07 18:16:41 (GMT) |
commit | 5c4de2863b217338deb9a0fcd20b202b8647b366 (patch) | |
tree | bba5ca1d16f518125a5d2bfb4fe32a362f5527d5 /Python/ceval.c | |
parent | a9296e7f3be4d6c22271b25c86467ff867c63bbb (diff) | |
download | cpython-5c4de2863b217338deb9a0fcd20b202b8647b366.zip cpython-5c4de2863b217338deb9a0fcd20b202b8647b366.tar.gz cpython-5c4de2863b217338deb9a0fcd20b202b8647b366.tar.bz2 |
Add the co_extra field and accompanying APIs to code objects.
This completes PEP 523.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index bf19a5b..9109ea5 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -5608,3 +5608,17 @@ _Py_GetDXProfile(PyObject *self, PyObject *args) } #endif + +Py_ssize_t +_PyEval_RequestCodeExtraIndex(freefunc free) +{ + PyThreadState *tstate = PyThreadState_Get(); + Py_ssize_t new_index; + + if (tstate->co_extra_user_count == MAX_CO_EXTRA_USERS - 1) { + return -1; + } + new_index = tstate->co_extra_user_count++; + tstate->co_extra_freefuncs[new_index] = free; + return new_index; +} |