Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {

#define FUNC_MAX_WATCHERS 8

struct _py_func_runtime_state {
struct _py_func_state {
uint32_t next_version;
};

Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ struct _is {
struct _Py_float_state float_state;
struct _Py_long_state long_state;
struct _dtoa_state dtoa;
struct _py_func_state func_state;
/* Using a cache is very effective since typically only a single slice is
created and then deleted again. */
PySliceObject *slice_cache;
Expand Down
2 changes: 0 additions & 2 deletions Include/internal/pycore_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ extern "C" {
#include "pycore_dict_state.h" // struct _Py_dict_runtime_state
#include "pycore_floatobject.h" // struct _Py_float_runtime_state
#include "pycore_faulthandler.h" // struct _faulthandler_runtime_state
#include "pycore_function.h" // struct _func_runtime_state
#include "pycore_global_objects.h" // struct _Py_global_objects
#include "pycore_import.h" // struct _import_runtime_state
#include "pycore_interp.h" // PyInterpreterState
Expand Down Expand Up @@ -155,7 +154,6 @@ typedef struct pyruntimestate {
struct _Py_float_runtime_state float_state;
struct _Py_unicode_runtime_state unicode_state;
struct _Py_dict_runtime_state dict_state;
struct _py_func_runtime_state func_state;

struct {
/* Used to set PyTypeObject.tp_version_tag */
Expand Down
6 changes: 3 additions & 3 deletions Include/internal/pycore_runtime_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ extern "C" {
.dict_state = { \
.next_keys_version = 2, \
}, \
.func_state = { \
.next_version = 1, \
}, \
.types = { \
.next_version_tag = 1, \
}, \
Expand Down Expand Up @@ -113,6 +110,9 @@ extern "C" {
}, \
}, \
.dtoa = _dtoa_state_INIT(&(INTERP)), \
.func_state = { \
.next_version = 1, \
}, \
.static_objects = { \
.singletons = { \
._not_used = 1, \
Expand Down
5 changes: 3 additions & 2 deletions Objects/funcobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func)
if (func->vectorcall != _PyFunction_Vectorcall) {
return 0;
}
if (_PyRuntime.func_state.next_version == 0) {
PyInterpreterState *interp = _PyInterpreterState_GET();
if (interp->func_state.next_version == 0) {
return 0;
}
uint32_t v = _PyRuntime.func_state.next_version++;
uint32_t v = interp->func_state.next_version++;
func->func_version = v;
return v;
}
Expand Down