Skip to content

Commit 2fde355

Browse files
authored
Merge branch 'main' into ipv6-address-parts
2 parents e1e6917 + d66c08a commit 2fde355

File tree

107 files changed

+3147
-1740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3147
-1740
lines changed

Doc/library/importlib.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,15 @@ ABC hierarchy::
380380

381381
.. class:: ResourceLoader
382382

383+
*Superseded by TraversableResources*
384+
383385
An abstract base class for a :term:`loader` which implements the optional
384386
:pep:`302` protocol for loading arbitrary resources from the storage
385387
back-end.
386388

387389
.. deprecated:: 3.7
388390
This ABC is deprecated in favour of supporting resource loading
389-
through :class:`importlib.resources.abc.ResourceReader`.
391+
through :class:`importlib.resources.abc.TraversableResources`.
390392

391393
.. abstractmethod:: get_data(path)
392394

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This module provides access to some variables used or maintained by the
1010
interpreter and to functions that interact strongly with the interpreter. It is
11-
always available.
11+
always available. Unless explicitly noted otherwise, all variables are read-only.
1212

1313

1414
.. data:: abiflags

Include/cpython/object.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@ partially-deallocated object. To check this, the tp_dealloc function must be
475475
passed as second argument to Py_TRASHCAN_BEGIN().
476476
*/
477477

478-
/* Python 3.9 private API, invoked by the macros below. */
479-
PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op);
480-
PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate);
481478

482479
PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyThreadState *tstate, PyObject *op);
483480
PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(PyThreadState *tstate);

Include/cpython/pystats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define PYSTATS_MAX_UOP_ID 512
3333

34-
#define SPECIALIZATION_FAILURE_KINDS 36
34+
#define SPECIALIZATION_FAILURE_KINDS 37
3535

3636
/* Stats for determining who is calling PyEval_EvalFrame */
3737
#define EVAL_CALL_TOTAL 0

Include/internal/pycore_code.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ typedef struct {
100100

101101
typedef struct {
102102
_Py_BackoffCounter counter;
103+
uint16_t external_cache[4];
103104
} _PyBinaryOpCache;
104105

105106
#define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache)
@@ -438,7 +439,7 @@ write_u64(uint16_t *p, uint64_t val)
438439
}
439440

440441
static inline void
441-
write_obj(uint16_t *p, PyObject *val)
442+
write_ptr(uint16_t *p, void *val)
442443
{
443444
memcpy(p, &val, sizeof(val));
444445
}
@@ -576,6 +577,16 @@ adaptive_counter_backoff(_Py_BackoffCounter counter) {
576577
return restart_backoff_counter(counter);
577578
}
578579

580+
/* Specialization Extensions */
581+
582+
/* callbacks for an external specialization */
583+
typedef int (*binaryopguardfunc)(PyObject *lhs, PyObject *rhs);
584+
typedef PyObject *(*binaryopactionfunc)(PyObject *lhs, PyObject *rhs);
585+
586+
typedef struct {
587+
binaryopguardfunc guard;
588+
binaryopactionfunc action;
589+
} _PyBinaryOpSpecializationDescr;
579590

580591
/* Comparison bit masks. */
581592

Include/internal/pycore_dict.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ extern Py_ssize_t _Py_dict_lookup_threadsafe_stackref(PyDictObject *mp, PyObject
114114

115115
extern Py_ssize_t _PyDict_LookupIndex(PyDictObject *, PyObject *);
116116
extern Py_ssize_t _PyDictKeys_StringLookup(PyDictKeysObject* dictkeys, PyObject *key);
117+
118+
/* Look up a string key in an all unicode dict keys, assign the keys object a version, and
119+
* store it in version.
120+
*
121+
* Returns DKIX_ERROR if key is not a string or if the keys object is not all
122+
* strings.
123+
*
124+
* Returns DKIX_EMPTY if the key is not present.
125+
*/
126+
extern Py_ssize_t _PyDictKeys_StringLookupAndVersion(PyDictKeysObject* dictkeys, PyObject *key, uint32_t *version);
117127
extern Py_ssize_t _PyDictKeys_StringLookupSplit(PyDictKeysObject* dictkeys, PyObject *key);
118128
PyAPI_FUNC(PyObject *)_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
119129
PyAPI_FUNC(void) _PyDict_LoadGlobalStackRef(PyDictObject *, PyDictObject *, PyObject *, _PyStackRef *);
@@ -337,8 +347,7 @@ PyDictObject *_PyObject_MaterializeManagedDict_LockHeld(PyObject *);
337347
static inline Py_ssize_t
338348
_PyDict_UniqueId(PyDictObject *mp)
339349
{
340-
// Offset by one so that _ma_watcher_tag=0 represents an unassigned id
341-
return (Py_ssize_t)(mp->_ma_watcher_tag >> DICT_UNIQUE_ID_SHIFT) - 1;
350+
return (Py_ssize_t)(mp->_ma_watcher_tag >> DICT_UNIQUE_ID_SHIFT);
342351
}
343352

344353
static inline void

Include/internal/pycore_gc.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ static inline PyObject* _Py_FROM_GC(PyGC_Head *gc) {
4545
* the per-object lock.
4646
*/
4747
#ifdef Py_GIL_DISABLED
48-
# define _PyGC_BITS_TRACKED (1) // Tracked by the GC
49-
# define _PyGC_BITS_FINALIZED (2) // tp_finalize was called
50-
# define _PyGC_BITS_UNREACHABLE (4)
51-
# define _PyGC_BITS_FROZEN (8)
52-
# define _PyGC_BITS_SHARED (16)
53-
# define _PyGC_BITS_DEFERRED (64) // Use deferred reference counting
48+
# define _PyGC_BITS_TRACKED (1<<0) // Tracked by the GC
49+
# define _PyGC_BITS_FINALIZED (1<<1) // tp_finalize was called
50+
# define _PyGC_BITS_UNREACHABLE (1<<2)
51+
# define _PyGC_BITS_FROZEN (1<<3)
52+
# define _PyGC_BITS_SHARED (1<<4)
53+
# define _PyGC_BITS_ALIVE (1<<5) // Reachable from a known root.
54+
# define _PyGC_BITS_DEFERRED (1<<6) // Use deferred reference counting
5455
#endif
5556

5657
#ifdef Py_GIL_DISABLED
@@ -330,6 +331,9 @@ struct _gc_runtime_state {
330331
collections, and are awaiting to undergo a full collection for
331332
the first time. */
332333
Py_ssize_t long_lived_pending;
334+
335+
/* True if gc.freeze() has been used. */
336+
int freeze_active;
333337
#endif
334338
};
335339

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ Known values:
266266
Python 3.14a4 3611 (Add NOT_TAKEN instruction)
267267
Python 3.14a4 3612 (Add POP_ITER and INSTRUMENTED_POP_ITER)
268268
Python 3.14a4 3613 (Add LOAD_CONST_MORTAL instruction)
269+
Python 3.14a5 3614 (Add BINARY_OP_EXTEND)
269270
270271
Python 3.15 will start with 3650
271272
@@ -278,7 +279,7 @@ PC/launcher.c must also be updated.
278279
279280
*/
280281

281-
#define PYC_MAGIC_NUMBER 3613
282+
#define PYC_MAGIC_NUMBER 3614
282283
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
283284
(little-endian) and then appending b'\r\n'. */
284285
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_object.h

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,6 @@ Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *op, Py_ssize_t extra);
299299
extern int _PyType_CheckConsistency(PyTypeObject *type);
300300
extern int _PyDict_CheckConsistency(PyObject *mp, int check_content);
301301

302-
/* Update the Python traceback of an object. This function must be called
303-
when a memory block is reused from a free list.
304-
305-
Internal function called by _Py_NewReference(). */
306-
extern int _PyTraceMalloc_TraceRef(PyObject *op, PyRefTracerEvent event, void*);
307-
308302
// Fast inlined version of PyType_HasFeature()
309303
static inline int
310304
_PyType_HasFeature(PyTypeObject *type, unsigned long feature) {
@@ -342,20 +336,20 @@ _Py_THREAD_INCREF_OBJECT(PyObject *obj, Py_ssize_t unique_id)
342336
{
343337
_PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET();
344338

345-
// Unsigned comparison so that `unique_id=-1`, which indicates that
346-
// per-thread refcounting has been disabled on this object, is handled by
347-
// the "else".
348-
if ((size_t)unique_id < (size_t)tstate->refcounts.size) {
339+
// The table index is `unique_id - 1` because 0 is not a valid unique id.
340+
// Unsigned comparison so that `idx=-1` is handled by the "else".
341+
size_t idx = (size_t)(unique_id - 1);
342+
if (idx < (size_t)tstate->refcounts.size) {
349343
# ifdef Py_REF_DEBUG
350344
_Py_INCREF_IncRefTotal();
351345
# endif
352346
_Py_INCREF_STAT_INC();
353-
tstate->refcounts.values[unique_id]++;
347+
tstate->refcounts.values[idx]++;
354348
}
355349
else {
356350
// The slow path resizes the per-thread refcount array if necessary.
357-
// It handles the unique_id=-1 case to keep the inlinable function smaller.
358-
_PyObject_ThreadIncrefSlow(obj, unique_id);
351+
// It handles the unique_id=0 case to keep the inlinable function smaller.
352+
_PyObject_ThreadIncrefSlow(obj, idx);
359353
}
360354
}
361355

@@ -392,15 +386,15 @@ _Py_THREAD_DECREF_OBJECT(PyObject *obj, Py_ssize_t unique_id)
392386
{
393387
_PyThreadStateImpl *tstate = (_PyThreadStateImpl *)_PyThreadState_GET();
394388

395-
// Unsigned comparison so that `unique_id=-1`, which indicates that
396-
// per-thread refcounting has been disabled on this object, is handled by
397-
// the "else".
398-
if ((size_t)unique_id < (size_t)tstate->refcounts.size) {
389+
// The table index is `unique_id - 1` because 0 is not a valid unique id.
390+
// Unsigned comparison so that `idx=-1` is handled by the "else".
391+
size_t idx = (size_t)(unique_id - 1);
392+
if (idx < (size_t)tstate->refcounts.size) {
399393
# ifdef Py_REF_DEBUG
400394
_Py_DECREF_DecRefTotal();
401395
# endif
402396
_Py_DECREF_STAT_INC();
403-
tstate->refcounts.values[unique_id]--;
397+
tstate->refcounts.values[idx]--;
404398
}
405399
else {
406400
// Directly decref the object if the id is not assigned or if

Include/internal/pycore_opcode_metadata.h

Lines changed: 30 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy