diff options
author | Thomas Wouters <thomas@python.org> | 2022-11-15 12:38:09 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2022-11-15 12:38:09 (GMT) |
commit | 73943cbc4c5e97f71b76150c549d07e8ed00066b (patch) | |
tree | 748ea6203fa3d36112565a67065e3a1bdc550b40 /Include | |
parent | bd58b89654a98cbfb92a6e054ac285bd32cdf58f (diff) | |
parent | f13f466474ed53529acd3f209070431fbae14323 (diff) | |
download | cpython-73943cbc4c5e97f71b76150c549d07e8ed00066b.zip cpython-73943cbc4c5e97f71b76150c549d07e8ed00066b.tar.gz cpython-73943cbc4c5e97f71b76150c549d07e8ed00066b.tar.bz2 |
Merge the 3.12.0a2 release into main.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/pystate.h | 3 | ||||
-rw-r--r-- | Include/internal/pycore_compile.h | 7 | ||||
-rw-r--r-- | Include/internal/pycore_global_objects.h | 12 | ||||
-rw-r--r-- | Include/internal/pycore_global_objects_fini_generated.h | 1 | ||||
-rw-r--r-- | Include/internal/pycore_global_strings.h | 1 | ||||
-rw-r--r-- | Include/internal/pycore_import.h | 11 | ||||
-rw-r--r-- | Include/internal/pycore_interp.h | 3 | ||||
-rw-r--r-- | Include/internal/pycore_runtime.h | 8 | ||||
-rw-r--r-- | Include/internal/pycore_runtime_init.h | 15 | ||||
-rw-r--r-- | Include/internal/pycore_runtime_init_generated.h | 1 | ||||
-rw-r--r-- | Include/internal/pycore_typeobject.h | 9 | ||||
-rw-r--r-- | Include/internal/pycore_unicodeobject_generated.h | 2 |
12 files changed, 65 insertions, 8 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h index 70c2342..c51542b 100644 --- a/Include/cpython/pystate.h +++ b/Include/cpython/pystate.h @@ -120,9 +120,6 @@ struct _ts { after allocation. */ int _initialized; - /* Was this thread state statically allocated? */ - int _static; - int py_recursion_remaining; int py_recursion_limit; diff --git a/Include/internal/pycore_compile.h b/Include/internal/pycore_compile.h index cb490ab..967fe92 100644 --- a/Include/internal/pycore_compile.h +++ b/Include/internal/pycore_compile.h @@ -40,6 +40,13 @@ extern int _PyAST_Optimize( _PyASTOptimizeState *state); /* Access compiler internals for unit testing */ + +PyAPI_FUNC(PyObject*) _PyCompile_CodeGen( + PyObject *ast, + PyObject *filename, + PyCompilerFlags *flags, + int optimize); + PyAPI_FUNC(PyObject*) _PyCompile_OptimizeCfg( PyObject *instructions, PyObject *consts); diff --git a/Include/internal/pycore_global_objects.h b/Include/internal/pycore_global_objects.h index 3561f68..5ad1f7d 100644 --- a/Include/internal/pycore_global_objects.h +++ b/Include/internal/pycore_global_objects.h @@ -10,6 +10,7 @@ extern "C" { #include "pycore_gc.h" // PyGC_Head #include "pycore_global_strings.h" // struct _Py_global_strings +#include "pycore_typeobject.h" // pytype_slotdef // These would be in pycore_long.h if it weren't for an include cycle. @@ -20,6 +21,13 @@ extern "C" { // Only immutable objects should be considered runtime-global. // All others must be per-interpreter. +#define _Py_CACHED_OBJECT(NAME) \ + _PyRuntime.cached_objects.NAME + +struct _Py_cached_objects { + PyObject *str_replace_inf; +}; + #define _Py_GLOBAL_OBJECT(NAME) \ _PyRuntime.global_objects.NAME #define _Py_SINGLETON(NAME) \ @@ -54,6 +62,10 @@ struct _Py_global_objects { struct _Py_interp_cached_objects { int _not_set; + /* object.__reduce__ */ + PyObject *objreduce; + PyObject *type_slots_pname; + pytype_slotdef *type_slots_ptrs[MAX_EQUIV]; }; #define _Py_INTERP_STATIC_OBJECT(interp, NAME) \ diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 8883bbb..0b5833c 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -781,6 +781,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arguments)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(argv)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(as_integer_ratio)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ast)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(attribute)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(authorizer_callback)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(autocommit)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 1227142..5bfd4be 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -267,6 +267,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(arguments) STRUCT_FOR_ID(argv) STRUCT_FOR_ID(as_integer_ratio) + STRUCT_FOR_ID(ast) STRUCT_FOR_ID(attribute) STRUCT_FOR_ID(authorizer_callback) STRUCT_FOR_ID(autocommit) diff --git a/Include/internal/pycore_import.h b/Include/internal/pycore_import.h index 7e8d73b..8ba9666 100644 --- a/Include/internal/pycore_import.h +++ b/Include/internal/pycore_import.h @@ -21,6 +21,17 @@ struct _import_runtime_state { This is initialized lazily in _PyImport_FixupExtensionObject(). Modules are added there and looked up in _imp.find_extension(). */ PyObject *extensions; + /* The global import lock. */ + struct { + PyThread_type_lock mutex; + unsigned long thread; + int level; + } lock; + struct { + int import_level; + _PyTime_t accumulated; + int header; + } find_and_load; }; diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index 976e16a..7c998ac 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -116,9 +116,6 @@ struct _is { int _initialized; int finalizing; - /* Was this interpreter statically allocated? */ - bool _static; - struct _ceval_state ceval; struct _gc_runtime_state gc; diff --git a/Include/internal/pycore_runtime.h b/Include/internal/pycore_runtime.h index a549068..6bcb35b 100644 --- a/Include/internal/pycore_runtime.h +++ b/Include/internal/pycore_runtime.h @@ -136,7 +136,15 @@ typedef struct pyruntimestate { struct _Py_unicode_runtime_ids unicode_ids; + struct { + /* Used to set PyTypeObject.tp_version_tag */ + // bpo-42745: next_version_tag remains shared by all interpreters + // because of static types. + unsigned int next_version_tag; + } types; + /* All the objects that are shared by the runtime's interpreters. */ + struct _Py_cached_objects cached_objects; struct _Py_global_objects global_objects; /* The following fields are here to avoid allocation during init. diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h index 38c1747..62d5063 100644 --- a/Include/internal/pycore_runtime_init.h +++ b/Include/internal/pycore_runtime_init.h @@ -36,6 +36,19 @@ extern "C" { until _PyInterpreterState_Enable() is called. */ \ .next_id = -1, \ }, \ + .types = { \ + .next_version_tag = 1, \ + }, \ + .imports = { \ + .lock = { \ + .mutex = NULL, \ + .thread = PYTHREAD_INVALID_THREAD_ID, \ + .level = 0, \ + }, \ + .find_and_load = { \ + .header = 1, \ + }, \ + }, \ .global_objects = { \ .singletons = { \ .small_ints = _Py_small_ints_INIT, \ @@ -70,7 +83,6 @@ extern "C" { #define _PyInterpreterState_INIT \ { \ - ._static = 1, \ .id_refcount = -1, \ DLOPENFLAGS_INIT \ .ceval = { \ @@ -95,7 +107,6 @@ extern "C" { #define _PyThreadState_INIT \ { \ - ._static = 1, \ .py_recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \ .context_ver = 1, \ } diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index e7fba8d..7228cb5 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -773,6 +773,7 @@ extern "C" { INIT_ID(arguments), \ INIT_ID(argv), \ INIT_ID(as_integer_ratio), \ + INIT_ID(ast), \ INIT_ID(attribute), \ INIT_ID(authorizer_callback), \ INIT_ID(autocommit), \ diff --git a/Include/internal/pycore_typeobject.h b/Include/internal/pycore_typeobject.h index 5e7aca1..71f3068 100644 --- a/Include/internal/pycore_typeobject.h +++ b/Include/internal/pycore_typeobject.h @@ -18,6 +18,15 @@ extern void _PyTypes_Fini(PyInterpreterState *); /* other API */ +/* Length of array of slotdef pointers used to store slots with the + same __name__. There should be at most MAX_EQUIV-1 slotdef entries with + the same __name__, for any __name__. Since that's a static property, it is + appropriate to declare fixed-size arrays for this. */ +#define MAX_EQUIV 10 + +typedef struct wrapperbase pytype_slotdef; + + // Type attribute lookup cache: speed up attribute and method lookups, // see _PyType_Lookup(). struct type_cache_entry { diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index ada0485..208a1e1 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -440,6 +440,8 @@ _PyUnicode_InitStaticStrings(void) { PyUnicode_InternInPlace(&string); string = &_Py_ID(as_integer_ratio); PyUnicode_InternInPlace(&string); + string = &_Py_ID(ast); + PyUnicode_InternInPlace(&string); string = &_Py_ID(attribute); PyUnicode_InternInPlace(&string); string = &_Py_ID(authorizer_callback); |