Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-81057: Move More Globals in Core Code to _PyRuntimeState#99516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
18 commits
Select commitHold shift + click to select a range
caec551
Drop outdated whitelist entries.
ericsnowcurrentlyNov 15, 2022
f6b90ee
Move make_pending_calls():busy to _PyRuntimeState.
ericsnowcurrentlyNov 15, 2022
a6be5a3
Move urandom_cache to _PyRuntimeState.
ericsnowcurrentlyNov 15, 2022
fb33ede
Move float_format/double_format to _PyRuntimeState.
ericsnowcurrentlyNov 15, 2022
bd1a66d
Special-case the hash secret.
ericsnowcurrentlyNov 15, 2022
1da0a33
Re-organize the ingored list.
ericsnowcurrentlyNov 15, 2022
03481e2
Drop an old global from the ingored list.
ericsnowcurrentlyNov 15, 2022
e50ea07
Only initialize bloom_linebreak once in the process.
ericsnowcurrentlyNov 15, 2022
a55e26a
Clarify an ignore list header.
ericsnowcurrentlyNov 15, 2022
fd3ec40
Move memo_statistics to the ignored list.
ericsnowcurrentlyNov 15, 2022
d04d9da
runtime.unicode_ids -> runtime.unicode_state.ids.
ericsnowcurrentlyNov 15, 2022
4e13ded
Move force_ascii to _PyRuntimeState.
ericsnowcurrentlyNov 15, 2022
e8ad283
Move _Py_PackageContext to _PyRuntimeState.
ericsnowcurrentlyNov 15, 2022
22135f7
Move _Py_FatalErrorFormat():reentrant to the ignored list.
ericsnowcurrentlyNov 15, 2022
426b34e
Move PyFPE_counter to the ignored list.
ericsnowcurrentlyNov 15, 2022
ffdd34a
Move _Py_UnhandledKeyboardInterrupt to _PyRuntimeState.
ericsnowcurrentlyNov 15, 2022
248a69c
Fix pyhash_runtime_state on Windows.
ericsnowcurrentlyNov 15, 2022
a4a55d1
Fix pyhash_runtime_state on Windows.
ericsnowcurrentlyNov 15, 2022
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
PrevPrevious commit
NextNext commit
Move float_format/double_format to _PyRuntimeState.
  • Loading branch information
@ericsnowcurrently
ericsnowcurrently committedNov 15, 2022
commitfb33edeffd47e6aa811bc89bd9d08e162c32246a
12 changes: 12 additions & 0 deletionsInclude/internal/pycore_floatobject.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,18 @@ extern void _PyFloat_FiniType(PyInterpreterState *);

/* other API */

enum _py_float_format_type {
_py_float_format_unknown,
_py_float_format_ieee_big_endian,
_py_float_format_ieee_little_endian,
};

struct _Py_float_runtime_state {
enum _py_float_format_type float_format;
enum _py_float_format_type double_format;
};


#ifndef WITH_FREELISTS
// without freelists
# define PyFloat_MAXFREELIST 0
Expand Down
2 changes: 2 additions & 0 deletionsInclude/internal/pycore_runtime.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@ extern "C" {

#include "pycore_atomic.h" /* _Py_atomic_address */
#include "pycore_dtoa.h" // struct _dtoa_runtime_state
#include "pycore_floatobject.h" // struct _Py_float_runtime_state
#include "pycore_gil.h" // struct _gil_runtime_state
#include "pycore_global_objects.h" // struct _Py_global_objects
#include "pycore_import.h" // struct _import_runtime_state
Expand DownExpand Up@@ -142,6 +143,7 @@ typedef struct pyruntimestate {
void *open_code_userdata;
_Py_AuditHookEntry *audit_hook_head;

struct _Py_float_runtime_state float_state;
struct _Py_unicode_runtime_ids unicode_ids;

struct {
Expand Down
30 changes: 17 additions & 13 deletionsInclude/internal/pycore_runtime_init.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,12 +19,6 @@ extern "C" {

#define _PyRuntimeState_INIT(runtime) \
{ \
.gilstate = { \
.check_enabled = 1, \
/* A TSS key must be initialized with Py_tss_NEEDS_INIT \
in accordance with the specification. */ \
.autoTSSkey = Py_tss_NEEDS_INIT, \
}, \
.allocators = { \
_pymem_allocators_standard_INIT(runtime), \
_pymem_allocators_debug_INIT, \
Expand All@@ -41,13 +35,6 @@ extern "C" {
until _PyInterpreterState_Enable() is called. */ \
.next_id = -1, \
}, \
.tracemalloc = { \
.config = _PyTraceMalloc_Config_INIT, \
}, \
.dtoa = _dtoa_runtime_state_INIT(runtime), \
.types = { \
.next_version_tag = 1, \
}, \
.imports = { \
.lock = { \
.mutex = NULL, \
Expand All@@ -58,6 +45,23 @@ extern "C" {
.header = 1, \
}, \
}, \
.gilstate = { \
.check_enabled = 1, \
/* A TSS key must be initialized with Py_tss_NEEDS_INIT \
in accordance with the specification. */ \
.autoTSSkey = Py_tss_NEEDS_INIT, \
}, \
.tracemalloc = { \
.config = _PyTraceMalloc_Config_INIT, \
}, \
.dtoa = _dtoa_runtime_state_INIT(runtime), \
.float_state = { \
.float_format = _py_float_format_unknown, \
.double_format = _py_float_format_unknown, \
}, \
.types = { \
.next_version_tag = 1, \
}, \
.global_objects = { \
.singletons = { \
.small_ints = _Py_small_ints_INIT, \
Expand Down
27 changes: 17 additions & 10 deletionsObjects/floatobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1723,12 +1723,14 @@ float___getnewargs___impl(PyObject *self)
}

/* this is for the benefit of the pack/unpack routines below */
typedef enum _py_float_format_type float_format_type;
#define unknown_format _py_float_format_unknown
#define ieee_big_endian_format _py_float_format_ieee_big_endian
#define ieee_little_endian_format _py_float_format_ieee_little_endian

typedef enum {
unknown_format, ieee_big_endian_format, ieee_little_endian_format
} float_format_type;
#define float_format (_PyRuntime.float_state.float_format)
#define double_format (_PyRuntime.float_state.double_format)

static float_format_type double_format, float_format;

/*[clinic input]
@classmethod
Expand DownExpand Up@@ -1929,13 +1931,9 @@ PyTypeObject PyFloat_Type = {
.tp_vectorcall = (vectorcallfunc)float_vectorcall,
};

void
_PyFloat_InitState(PyInterpreterState *interp)
staticvoid
_init_global_state(void)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}

float_format_type detected_double_format, detected_float_format;

/* We attempt to determine if this machine is using IEEE
Expand DownExpand Up@@ -1985,6 +1983,15 @@ _PyFloat_InitState(PyInterpreterState *interp)
float_format = detected_float_format;
}

void
_PyFloat_InitState(PyInterpreterState *interp)
{
if (!_Py_IsMainInterpreter(interp)) {
return;
}
_init_global_state();
}

PyStatus
_PyFloat_InitTypes(PyInterpreterState *interp)
{
Expand Down
2 changes: 0 additions & 2 deletionsTools/c-analyzer/cpython/ignored.tsv
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,8 +48,6 @@ Python/getversion.c-version-
#-----------------------
# effectively const, initialized during init

Objects/floatobject.c-double_format-
Objects/floatobject.c-float_format-
Objects/unicodeobject.c-bloom_linebreak-
Python/bootstrap_hash.cpy_getrandomgetrandom_works-
Python/bootstrap_hash.c-_Py_HashSecret_Initialized-
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp