8000 Merge remote-tracking branch 'upstream/main' · python/cpython@2402f1e · GitHub
[go: up one dir, main page]

Skip to content

Commit 2402f1e

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 01d4fe0 + c5640ef commit 2402f1e

33 files changed

+918
-732
lines changed

Doc/library/timeit.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ It is possible to provide a setup statement that is executed only once at the be
282282
$ python -m timeit -s 'text = "sample string"; char = "g"' 'text.find(char)'
283283
1000000 loops, best of 5: 0.342 usec per loop
284284
285+
In the output, there are three fields. The loop count, which tells you how many
286+
times the statement body was run per timing loop repetition. The repetition
287+
count ('best of 5') which tells you how many times the timing loop was
288+
repeated, and finally the time the statement body took on average within the
289+
best repetition of the timing loop. That is, the time the fastest repetition
290+
took divided by the loop count.
291+
285292
::
286293

287294
>>> import timeit

Doc/using/configure.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ General Options
3535

3636
Define the size in bits of Python :class:`int` digits: 15 or 30 bits.
3737

38-
By default, the number of bits is selected depending on ``sizeof(void*)``:
39-
30 bits if ``void*`` size is 64-bit or larger, 15 bits otherwise.
38+
By default, the digit size is 30.
4039

4140
Define the ``PYLONG_BITS_IN_DIGIT`` to ``15`` or ``30``.
4241

Doc/whatsnew/3.11.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,16 @@ Build Changes
622622
like Pyodide.
623623
(Contributed by Christian Heimes and Ethan Smith in :issue:`40280`.)
624624

625+
* CPython will now use 30-bit digits by default for the Python :class:`int`
626 6DB6 +
implementation. Previously, the default was to use 30-bit digits on platforms
627+
with ``SIZEOF_VOID_P >= 8``, and 15-bit digits otherwise. It's still possible
628+
to explicitly request use of 15-bit digits via either the
629+
``--enable-big-digits`` option to the configure script or (for Windows) the
630+
``PYLONG_BITS_IN_DIGIT`` variable in ``PC/pyconfig.h``, but this option may
631+
be removed at some point in the future. (Contributed by Mark Dickinson in
632+
:issue:`45569`.)
633+
634+
625635
C API Changes
626636
=============
627637

Include/cpython/pystate.h

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,19 @@ typedef struct _cframe {
5353
} CFrame;
5454

5555
typedef struct _err_stackitem {
56-
/* This struct represents an entry on the exception stack, which is a
57-
* per-coroutine state. (Coroutine in the computer science sense,
58-
* including the thread and generators).
59-
* This ensures that the exception state is not impacted by "yields"
60-
* from an except handler.
56+
/* This struct represents a single execution context where we might
57+
* be currently handling an exception. It is a per-coroutine state
58+
* (coroutine in the computer science sense, including the thread
59+
* and generators).
60+
*
61+
* This is used as an entry on the exception stack, where each
62+
* entry indicates if it is currently handling an exception.
63+
* This ensures that the exception state is not impacted
64+
* by "yields" from an except handler. The thread
65+
* always has an entry (the bottom-most one).
6166
*/
67+
68+
/* The exception currently being handled in this context, if any. */
6269
PyObject *exc_value;
6370

6471
struct _err_stackitem *previous_item;
@@ -112,13 +119,9 @@ struct _ts {
112119
PyObject *curexc_value;
113120
PyObject *curexc_traceback;
114121

115-
/* The exception currently being handled, if no coroutines/generators
116-
* are present. Always last element on the stack referred to be exc_info.
117-
*/
118-
_PyErr_StackItem exc_state;
119-
120-
/* Pointer to the top of the stack of the exceptions currently
121-
* being handled */
122+
/* Pointer to the top of the exception stack for the exceptions
123+
* we may be currently handling. (See _PyErr_StackItem above.)
124+
* This is never NULL. */
122125
_PyErr_StackItem *exc_info;
123126

124127
PyObject *dict; /* Stores per-thread state */
@@ -174,13 +177,26 @@ struct _ts {
174177
/* Unique thread state id. */
175178
uint64_t id;
176179

177-
CFrame root_cframe;
178180
PyTraceInfo trace_info;
179181

180182
_PyStackChunk *datastack_chunk;
181183
PyObject **datastack_top;
182184
PyObject **datastack_limit;
183185
/* XXX signal handlers should also be here */
186+
187+
/* The following fields are here to avoid allocation during init.
188+
The data is exposed through PyThreadState pointer fields.
189+
These fields should not be accessed directly outside of init.
190+
191+
All other PyInterpreterState pointer fields are populated when
192+
needed and default to NULL.
193+
*/
194+
195+
/* The thread's exception stack entry. (Always the last entry.) */
196+
_PyErr_StackItem _exc_state;
197+
198+
/* The bottom-most frame on the stack. */
199+
CFrame _root_cframe;
184200
};
185201

186202

Include/internal/pycore_ceval.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ extern "C" {
1212
struct pyruntimestate;
1313
struct _ceval_runtime_state;
1414

15+
#ifndef Py_DEFAULT_RECURSION_LIMIT
16+
# define Py_DEFAULT_RECURSION_LIMIT 1000
17+
#endif
18+
1519
#include "pycore_interp.h" // PyInterpreterState.eval_frame
1620
#include "pycore_pystate.h" // _PyThreadState_GET()
1721

22+
1823
extern void _Py_FinishPendingCalls(PyThreadState *tstate);
1924
extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
2025
extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock);

Include/internal/pycore_fileutils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ extern int _Py_EncodeNonUnicodeWchar_InPlace(
235235

236236
extern int _Py_isabs(const wchar_t *path);
237237
extern int _Py_abspath(const wchar_t *path, wchar_t **abspath_p);
238+
#ifdef MS_WINDOWS
239+
extern int _PyOS_getfullpathname(const wchar_t *path, wchar_t **abspath_p);
240+
#endif
238241
extern wchar_t * _Py_join_relfile(const wchar_t *dirname,
239242
const wchar_t *relfile);
240243
extern int _Py_add_relfile(wchar_t *dirname,

Include/internal/pycore_gc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct _gc_runtime_state {
134134
/* Current call-stack depth of tp_dealloc calls. */
135135
int trash_delete_nesting;
136136

137+
/* Is automatic collection enabled? */
137138
int enabled;
138139
int debug;
139140
/* linked lists of container objects */
@@ -161,6 +162,7 @@ struct _gc_runtime_state {
161162
Py_ssize_t long_lived_pending;
162163
};
163164

165+
164166
extern void _PyGC_InitState(struct _gc_runtime_state *);
165167

166168
extern Py_ssize_t _PyGC_CollectNoFail(PyThreadState *tstate);

0 commit comments

Comments
 (0)
0