diff options
author | Mark Shannon <mark@hotpy.org> | 2022-12-09 12:18:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-09 12:18:45 +0000 |
commit | fb713b21833a17cba8022af0fa4c486512157d4b (patch) | |
tree | 2e75f1e59393160792f1097846a648ff7927de8d /Objects/codeobject.c | |
parent | 3c5355496b54fa0a4ea0e22344d008528e45682c (diff) | |
download | cpython-git-fb713b21833a17cba8022af0fa4c486512157d4b.tar.gz |
GH-98522: Add version number to code objects. (GH-98525)
* Add version number to code object for better versioning of functions.
* Improves specialization for closures and list comprehensions.
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r-- | Objects/codeobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 0c197d767b..c92c7deaf8 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -11,7 +11,6 @@ #include "pycore_tuple.h" // _PyTuple_ITEMS() #include "clinic/codeobject.c.h" - static void notify_code_watchers(PyCodeEvent event, PyCodeObject *co) { @@ -398,7 +397,10 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con) co->co_nplaincellvars = nplaincellvars; co->co_ncellvars = ncellvars; co->co_nfreevars = nfreevars; - + co->co_version = _Py_next_func_version; + if (_Py_next_func_version != 0) { + _Py_next_func_version++; + } /* not set */ co->co_weakreflist = NULL; co->co_extra = NULL; |