Skip to content

Commit 99a3d6b

Browse files
authored
Merge branch 'main' into pyrepl_underscored_fix
2 parents 1e88864 + c91ad5d commit 99a3d6b

Some content is hidden

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

54 files changed

+823
-463
lines changed

Doc/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@
308308
('py:attr', '__annotations__'),
309309
('py:meth', '__missing__'),
310310
('py:attr', '__wrapped__'),
311-
('py:attr', 'decimal.Context.clamp'),
312311
('py:meth', 'index'), # list.index, tuple.index, etc.
313312
]
314313

Doc/library/datetime.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,11 +1502,11 @@ Instance methods:
15021502
returned by :func:`time.time`.
15031503

15041504
Naive :class:`.datetime` instances are assumed to represent local
1505-
time and this method relies on the platform C :c:func:`mktime`
1506-
function to perform the conversion. Since :class:`.datetime`
1507-
supports wider range of values than :c:func:`mktime` on many
1508-
platforms, this method may raise :exc:`OverflowError` or :exc:`OSError`
1509-
for times far in the past or far in the future.
1505+
time and this method relies on platform C functions to perform
1506+
the conversion. Since :class:`.datetime` supports a wider range of
1507+
values than the platform C functions on many platforms, this
1508+
method may raise :exc:`OverflowError` or :exc:`OSError` for times
1509+
far in the past or far in the future.
15101510

15111511
For aware :class:`.datetime` instances, the return value is computed
15121512
as::
@@ -1519,6 +1519,10 @@ Instance methods:
15191519
The :meth:`timestamp` method uses the :attr:`.fold` attribute to
15201520
disambiguate the times during a repeated interval.
15211521

1522+
.. versionchanged:: 3.6
1523+
This method no longer relies on the platform C :c:func:`mktime`
1524+
function to perform conversions.
1525+
15221526
.. note::
15231527

15241528
There is no method to obtain the POSIX timestamp directly from a

Doc/library/decimal.rst

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
=====================================================================
33

44
.. module:: decimal
5-
:synopsis: Implementation of the General Decimal Arithmetic Specification.
5+
:synopsis: Implementation of the General Decimal Arithmetic Specification.
66

77
.. moduleauthor:: Eric Price <eprice at tjhsst.edu>
88
.. moduleauthor:: Facundo Batista <facundo at taniquetil.com.ar>
@@ -121,7 +121,7 @@ reset them before monitoring a calculation.
121121
122122
.. _decimal-tutorial:
123123

124-
Quick-start Tutorial
124+
Quick-start tutorial
125125
--------------------
126126

127127
The usual start to using decimals is importing the module, viewing the current
@@ -1096,40 +1096,52 @@ In addition to the three supplied contexts, new contexts can be created with the
10961096
default values are copied from the :const:`DefaultContext`. If the *flags*
10971097
field is not specified or is :const:`None`, all flags are cleared.
10981098

1099-
*prec* is an integer in the range [``1``, :const:`MAX_PREC`] that sets
1100-
the precision for arithmetic operations in the context.
1099+
.. attribute:: prec
11011100

1102-
The *rounding* option is one of the constants listed in the section
1103-
`Rounding Modes`_.
1101+
An integer in the range [``1``, :const:`MAX_PREC`] that sets
1102+
the precision for arithmetic operations in the context.
11041103

1105-
The *traps* and *flags* fields list any signals to be set. Generally, new
1106-
contexts should only set traps and leave the flags clear.
1104+
.. attribute:: rounding
11071105

1108-
The *Emin* and *Emax* fields are integers specifying the outer limits allowable
1109-
for exponents. *Emin* must be in the range [:const:`MIN_EMIN`, ``0``],
1110-
*Emax* in the range [``0``, :const:`MAX_EMAX`].
1106+
One of the constants listed in the section `Rounding Modes`_.
11111107

1112-
The *capitals* field is either ``0`` or ``1`` (the default). If set to
1113-
``1``, exponents are printed with a capital ``E``; otherwise, a
1114-
lowercase ``e`` is used: ``Decimal('6.02e+23')``.
1108+
.. attribute:: traps
1109+
flags
11151110

1116-
The *clamp* field is either ``0`` (the default) or ``1``.
1117-
If set to ``1``, the exponent ``e`` of a :class:`Decimal`
1118-
instance representable in this context is strictly limited to the
1119-
range ``Emin - prec + 1 <= e <= Emax - prec + 1``. If *clamp* is
1120-
``0`` then a weaker condition holds: the adjusted exponent of
1121-
the :class:`Decimal` instance is at most :attr:`~Context.Emax`. When *clamp* is
1122-
``1``, a large normal number will, where possible, have its
1123-
exponent reduced and a corresponding number of zeros added to its
1124-
coefficient, in order to fit the exponent constraints; this
1125-
preserves the value of the number but loses information about
1126-
significant trailing zeros. For example::
1111+
Lists of any signals to be set. Generally, new contexts should only set
1112+
traps and leave the flags clear.
11271113

1128-
>>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
1129-
Decimal('1.23000E+999')
1114+
.. attribute:: Emin
1115+
Emax
11301116

1131-
A *clamp* value of ``1`` allows compatibility with the
1132-
fixed-width decimal interchange formats specified in IEEE 754.
1117+
Integers specifying the outer limits allowable for exponents. *Emin* must
1118+
be in the range [:const:`MIN_EMIN`, ``0``], *Emax* in the range
1119+
[``0``, :const:`MAX_EMAX`].
1120+
1121+
.. attribute:: capitals
1122+
1123+
Either ``0`` or ``1`` (the default). If set to
1124+
``1``, exponents are printed with a capital ``E``; otherwise, a
1125+
lowercase ``e`` is used: ``Decimal('6.02e+23')``.
1126+
1127+
.. attribute:: clamp
1128+
1129+
Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e``
1130+
of a :class:`Decimal` instance representable in this context is strictly
1131+
limited to the range ``Emin - prec + 1 <= e <= Emax - prec + 1``.
1132+
If *clamp* is ``0`` then a weaker condition holds: the adjusted exponent of
1133+
the :class:`Decimal` instance is at most :attr:`~Context.Emax`. When *clamp* is
1134+
``1``, a large normal number will, where possible, have its
1135+
exponent reduced and a corresponding number of zeros added to its
1136+
coefficient, in order to fit the exponent constraints; this
1137+
preserves the value of the number but loses information about
1138+
significant trailing zeros. For example::
1139+
1140+
>>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
1141+
Decimal('1.23000E+999')
1142+
1143+
A *clamp* value of ``1`` allows compatibility with the
1144+
fixed-width decimal interchange formats specified in IEEE 754.
11331145

11341146
The :class:`Context` class defines several general purpose methods as well as
11351147
a large number of methods for doing arithmetic directly in a given context.
@@ -1769,7 +1781,7 @@ The following table summarizes the hierarchy of signals::
17691781
17701782
.. _decimal-notes:
17711783

1772-
Floating-Point Notes
1784+
Floating-point notes
17731785
--------------------
17741786

17751787

Doc/library/io.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,10 @@ Text I/O
894894

895895
.. attribute:: buffer
896896

897-
The underlying binary buffer (a :class:`BufferedIOBase` instance) that
898-
:class:`TextIOBase` deals with. This is not part of the
899-
:class:`TextIOBase` API and may not exist in some implementations.
897+
The underlying binary buffer (a :class:`BufferedIOBase`
898+
or :class:`RawIOBase` instance) that :class:`TextIOBase` deals with.
899+
This is not part of the :class:`TextIOBase` API and may not exist
900+
in some implementations.
900901

901902
.. method:: detach()
902903

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Doc/c-api/typeobj.rst
1414
Doc/extending/extending.rst
1515
Doc/library/ast.rst
1616
Doc/library/asyncio-extending.rst
17-
Doc/library/decimal.rst
1817
Doc/library/email.charset.rst
1918
Doc/library/email.compat32-message.rst
2019
Doc/library/email.parser.rst

Doc/whatsnew/3.14.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,9 @@ ctypes
12001200
making it a :term:`generic type`.
12011201
(Contributed by Brian Schubert in :gh:`132168`.)
12021202

1203+
* :mod:`ctypes` now supports :term:`free-threading builds <free threading>`.
1204+
(Contributed by Kumar Aditya and Peter Bierma in :gh:`127945`.)
1205+
12031206
curses
12041207
------
12051208

@@ -1997,11 +2000,19 @@ Optimizations
19972000
asyncio
19982001
-------
19992002

2000-
* :mod:`asyncio` now uses double linked list implementation for native tasks
2001-
which speeds up execution by 10% on standard pyperformance benchmarks and
2002-
reduces memory usage.
2003+
* :mod:`asyncio` has a new per-thread double linked list implementation internally for
2004+
:class:`native tasks <asyncio.Task>` which speeds up execution by 10-20% on standard
2005+
pyperformance benchmarks and reduces memory usage.
2006+
This enables external introspection tools such as
2007+
:ref:`python -m asyncio pstree <whatsnew314-asyncio-introspection>`
2008+
to introspect the call graph of asyncio tasks running in all threads.
20032009
(Contributed by Kumar Aditya in :gh:`107803`.)
20042010

2011+
* :mod:`asyncio` has first class support for :term:`free-threading builds <free threading>`.
2012+
This enables parallel execution of multiple event loops across different threads and scales
2013+
linearly with the number of threads.
2014+
(Contributed by Kumar Aditya in :gh:`128002`.)
2015+
20052016
* :mod:`asyncio` has new utility functions for introspecting and printing
20062017
the program's call graph: :func:`asyncio.capture_call_graph` and
20072018
:func:`asyncio.print_call_graph`.
@@ -2083,7 +2094,6 @@ Deprecated
20832094
* :class:`asyncio.WindowsProactorEventLoopPolicy`
20842095
* :func:`asyncio.get_event_loop_policy`
20852096
* :func:`asyncio.set_event_loop_policy`
2086-
* :func:`asyncio.set_event_loop`
20872097

20882098
Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with
20892099
*loop_factory* to use the desired event loop implementation.

Include/internal/mimalloc/mimalloc/internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,10 @@ static inline mi_block_t* mi_block_nextx( const void* null, const mi_block_t* bl
634634
mi_track_mem_defined(block,sizeof(mi_block_t));
635635
mi_block_t* next;
636636
#ifdef MI_ENCODE_FREELIST
637-
next = (mi_block_t*)mi_ptr_decode(null, block->next, keys);
637+
next = (mi_block_t*)mi_ptr_decode(null, mi_atomic_load_relaxed(&block->next), keys);
638638
#else
639639
MI_UNUSED(keys); MI_UNUSED(null);
640-
next = (mi_block_t*)block->next;
640+
next = (mi_block_t*)mi_atomic_load_relaxed(&block->next);
641641
#endif
642642
mi_track_mem_noaccess(block,sizeof(mi_block_t));
643643
return next;
@@ -646,10 +646,10 @@ static inline mi_block_t* mi_block_nextx( const void* null, const mi_block_t* bl
646646
static inline void mi_block_set_nextx(const void* null, mi_block_t* block, const mi_block_t* next, const uintptr_t* keys) {
647647
mi_track_mem_undefined(block,sizeof(mi_block_t));
648648
#ifdef MI_ENCODE_FREELIST
649-
block->next = mi_ptr_encode(null, next, keys);
649+
mi_atomic_store_relaxed(&block->next, mi_ptr_encode(null, next, keys));
650650
#else
651651
MI_UNUSED(keys); MI_UNUSED(null);
652-
block->next = (mi_encoded_t)next;
652+
mi_atomic_store_relaxed(&block->next, (mi_encoded_t)next);
653653
#endif
654654
mi_track_mem_noaccess(block,sizeof(mi_block_t));
655655
}

Include/internal/mimalloc/mimalloc/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ typedef size_t mi_threadid_t;
235235

236236
// free lists contain blocks
237237
typedef struct mi_block_s {
238-
mi_encoded_t next;
238+
_Atomic(mi_encoded_t) next;
239239
} mi_block_t;
240240

241241

Include/internal/pycore_debug_offsets.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ extern "C" {
5252
#ifdef Py_GIL_DISABLED
5353
# define _Py_Debug_gilruntimestate_enabled offsetof(struct _gil_runtime_state, enabled)
5454
# define _Py_Debug_Free_Threaded 1
55+
# define _Py_Debug_code_object_co_tlbc offsetof(PyCodeObject, co_tlbc)
56+
# define _Py_Debug_interpreter_frame_tlbc_index offsetof(_PyInterpreterFrame, tlbc_index)
5557
#else
5658
# define _Py_Debug_gilruntimestate_enabled 0
5759
# define _Py_Debug_Free_Threaded 0
60+
# define _Py_Debug_code_object_co_tlbc 0
61+
# define _Py_Debug_interpreter_frame_tlbc_index 0
5862
#endif
5963

6064

@@ -109,6 +113,7 @@ typedef struct _Py_DebugOffsets {
109113
uint64_t localsplus;
110114
uint64_t owner;
111115
uint64_t stackpointer;
116+
uint64_t tlbc_index;
112117
} interpreter_frame;
113118

114119
// Code object offset;
@@ -123,6 +128,7 @@ typedef struct _Py_DebugOffsets {
123128
uint64_t localsplusnames;
124129
uint64_t localspluskinds;
125130
uint64_t co_code_adaptive;
131+
uint64_t co_tlbc;
126132
} code_object;
127133

128134
// PyObject offset;
@@ -265,6 +271,7 @@ typedef struct _Py_DebugOffsets {
265271
.localsplus = offsetof(_PyInterpreterFrame, localsplus), \
266272
.owner = offsetof(_PyInterpreterFrame, owner), \
267273
.stackpointer = offsetof(_PyInterpreterFrame, stackpointer), \
274+
.tlbc_index = _Py_Debug_interpreter_frame_tlbc_index, \
268275
}, \
269276
.code_object = { \
270277
.size = sizeof(PyCodeObject), \
@@ -277,6 +284,7 @@ typedef struct _Py_DebugOffsets {
277284
.localsplusnames = offsetof(PyCodeObject, co_localsplusnames), \
278285
.localspluskinds = offsetof(PyCodeObject, co_localspluskinds), \
279286
.co_code_adaptive = offsetof(PyCodeObject, co_code_adaptive), \
287+
.co_tlbc = _Py_Debug_code_object_co_tlbc, \
280288
}, \
281289
.pyobject = { \
282290
.size = sizeof(PyObject), \

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ Known values:
278278
Python 3.14a7 3623 (Add BUILD_INTERPOLATION & BUILD_TEMPLATE opcodes)
279279
Python 3.14b1 3624 (Don't optimize LOAD_FAST when local is killed by DELETE_FAST)
280280
Python 3.15a0 3650 (Initial version)
281+
Python 3.15a1 3651 (Simplify LOAD_CONST)
281282
282283
Python 3.16 will start with 3700
283284
@@ -290,7 +291,7 @@ PC/launcher.c must also be updated.
290291
291292
*/
292293

293-
#define PYC_MAGIC_NUMBER 3650
294+
#define PYC_MAGIC_NUMBER 3651
294295
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
295296
(little-endian) and then appending b'\r\n'. */
296297
#define PYC_MAGIC_NUMBER_TOKEN \

0 commit comments

Comments
 (0)