Skip to content

Commit 7cd7b75

Browse files
author
Erlend E. Aasland
committed
Merge branch 'main' into ac-sqlite
2 parents 9bc5d7b + ec382fa commit 7cd7b75

File tree

82 files changed

+3170
-2284
lines changed

Some content is hidden

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

82 files changed

+3170
-2284
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Modules/clinic/*.h linguist-generated=true
4646
Objects/clinic/*.h linguist-generated=true
4747
PC/clinic/*.h linguist-generated=true
4848
Python/clinic/*.h linguist-generated=true
49+
Python/deepfreeze/*.c linguist-generated=true
4950
Python/frozen_modules/*.h linguist-generated=true
5051
Python/frozen_modules/MANIFEST linguist-generated=true
5152
Include/internal/pycore_ast.h linguist-generated=true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Lib/distutils/command/*.pdb
5959
Lib/lib2to3/*.pickle
6060
Lib/test/data/*
6161
!Lib/test/data/README
62+
/_bootstrap_python
6263
/Makefile
6364
/Makefile.pre
6465
Mac/Makefile
@@ -115,6 +116,7 @@ Tools/unicode/data/
115116
/platform
116117
/profile-clean-stamp
117118
/profile-run-stamp
119+
/Python/deepfreeze/*.c
118120
/pybuilddir.txt
119121
/pyconfig.h
120122
/python-config

Doc/library/__main__.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ Idiomatic Usage
116116
^^^^^^^^^^^^^^^
117117

118118
Some modules contain code that is intended for script use only, like parsing
119-
command-line arguments or fetching data from standard input. When a module
120-
like this were to be imported from a different module, for example to unit test
119+
command-line arguments or fetching data from standard input. If a module
120+
like this was imported from a different module, for example to unit test
121121
it, the script code would unintentionally execute as well.
122122

123123
This is where using the ``if __name__ == '__main__'`` code block comes in

Doc/library/contextvars.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Context Variables
9494
# var.get() would raise a LookupError.
9595

9696

97-
.. class:: contextvars.Token
97+
.. class:: Token
9898

9999
*Token* objects are returned by the :meth:`ContextVar.set` method.
100100
They can be passed to the :meth:`ContextVar.reset` method to revert

Doc/library/copy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The :func:`deepcopy` function avoids these problems by:
6060
components copied.
6161

6262
This module does not copy types like module, method, stack trace, stack frame,
63-
file, socket, window, array, or any similar types. It does "copy" functions and
63+
file, socket, window, or any similar types. It does "copy" functions and
6464
classes (shallow and deeply), by returning the original object unchanged; this
6565
is compatible with the way these are treated by the :mod:`pickle` module.
6666

Doc/library/ctypes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,9 @@ size, we show only how this table can be read with :mod:`ctypes`::
10871087
>>> class struct_frozen(Structure):
10881088
... _fields_ = [("name", c_char_p),
10891089
... ("code", POINTER(c_ubyte)),
1090-
... ("size", c_int)]
1090+
... ("size", c_int),
1091+
... ("get_code", POINTER(c_ubyte)), # Function pointer
1092+
... ]
10911093
...
10921094
>>>
10931095

Doc/library/dis.rst

Lines changed: 11 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -406,156 +406,29 @@ result back on the stack.
406406
.. versionadded:: 3.5
407407

408408

409-
**Binary operations**
409+
**Binary and in-place operations**
410410

411411
Binary operations remove the top of the stack (TOS) and the second top-most
412412
stack item (TOS1) from the stack. They perform the operation, and put the
413413
result back on the stack.
414414

415-
.. opcode:: BINARY_POWER
416-
417-
Implements ``TOS = TOS1 ** TOS``.
418-
419-
420-
.. opcode:: BINARY_MULTIPLY
421-
422-
Implements ``TOS = TOS1 * TOS``.
423-
424-
425-
.. opcode:: BINARY_MATRIX_MULTIPLY
426-
427-
Implements ``TOS = TOS1 @ TOS``.
428-
429-
.. versionadded:: 3.5
430-
431-
432-
.. opcode:: BINARY_FLOOR_DIVIDE
433-
434-
Implements ``TOS = TOS1 // TOS``.
435-
436-
437-
.. opcode:: BINARY_TRUE_DIVIDE
438-
439-
Implements ``TOS = TOS1 / TOS``.
440-
441-
442-
.. opcode:: BINARY_MODULO
443-
444-
Implements ``TOS = TOS1 % TOS``.
445-
446-
447-
.. opcode:: BINARY_ADD
448-
449-
Implements ``TOS = TOS1 + TOS``.
450-
451-
452-
.. opcode:: BINARY_SUBTRACT
453-
454-
Implements ``TOS = TOS1 - TOS``.
455-
456-
457-
.. opcode:: BINARY_SUBSCR
458-
459-
Implements ``TOS = TOS1[TOS]``.
460-
461-
462-
.. opcode:: BINARY_LSHIFT
463-
464-
Implements ``TOS = TOS1 << TOS``.
465-
466-
467-
.. opcode:: BINARY_RSHIFT
468-
469-
Implements ``TOS = TOS1 >> TOS``.
470-
471-
472-
.. opcode:: BINARY_AND
473-
474-
Implements ``TOS = TOS1 & TOS``.
475-
476-
477-
.. opcode:: BINARY_XOR
478-
479-
Implements ``TOS = TOS1 ^ TOS``.
480-
481-
482-
.. opcode:: BINARY_OR
483-
484-
Implements ``TOS = TOS1 | TOS``.
485-
486-
487-
**In-place operations**
488-
489415
In-place operations are like binary operations, in that they remove TOS and
490416
TOS1, and push the result back on the stack, but the operation is done in-place
491417
when TOS1 supports it, and the resulting TOS may be (but does not have to be)
492418
the original TOS1.
493419

494-
.. opcode:: INPLACE_POWER
495-
496-
Implements in-place ``TOS = TOS1 ** TOS``.
497-
498-
499-
.. opcode:: INPLACE_MULTIPLY
500-
501-
Implements in-place ``TOS = TOS1 * TOS``.
502-
503-
504-
.. opcode:: INPLACE_MATRIX_MULTIPLY
505-
506-
Implements in-place ``TOS = TOS1 @ TOS``.
507-
508-
.. versionadded:: 3.5
509-
510-
511-
.. opcode:: INPLACE_FLOOR_DIVIDE
512-
513-
Implements in-place ``TOS = TOS1 // TOS``.
514-
515-
516-
.. opcode:: INPLACE_TRUE_DIVIDE
517-
518-
Implements in-place ``TOS = TOS1 / TOS``.
519-
520-
521-
.. opcode:: INPLACE_MODULO
522420

523-
Implements in-place ``TOS = TOS1 % TOS``.
421+
.. opcode:: BINARY_OP (op)
524422

423+
Implements the binary and in-place operators (depending on the value of
424+
*op*).
525425

526-
.. opcode:: INPLACE_ADD
527-
528-
Implements in-place ``TOS = TOS1 + TOS``.
529-
530-
531-
.. opcode:: INPLACE_SUBTRACT
532-
533-
Implements in-place ``TOS = TOS1 - TOS``.
534-
535-
536-
.. opcode:: INPLACE_LSHIFT
537-
538-
Implements in-place ``TOS = TOS1 << TOS``.
539-
540-
541-
.. opcode:: INPLACE_RSHIFT
542-
543-
Implements in-place ``TOS = TOS1 >> TOS``.
544-
545-
546-
.. opcode:: INPLACE_AND
547-
548-
Implements in-place ``TOS = TOS1 & TOS``.
549-
550-
551-
.. opcode:: INPLACE_XOR
552-
553-
Implements in-place ``TOS = TOS1 ^ TOS``.
426+
.. versionadded:: 3.11
554427

555428

556-
.. opcode:: INPLACE_OR
429+
.. opcode:: BINARY_SUBSCR
557430

558-
Implements in-place ``TOS = TOS1 | TOS``.
431+
Implements ``TOS = TOS1[TOS]``.
559432

560433

561434
.. opcode:: STORE_SUBSCR
@@ -1000,10 +873,13 @@ All of the following opcodes use their arguments.
1000873
.. opcode:: JUMP_IF_NOT_EXC_MATCH (target)
1001874

1002875
Tests whether the second value on the stack is an exception matching TOS,
1003-
and jumps if it is not. Pops two values from the stack.
876+
and jumps if it is not. Pops one value from the stack.
1004877

1005878
.. versionadded:: 3.9
1006879

880+
.. versionchanged:: 3.11
881+
This opcode no longer pops the active exception.
882+
1007883

1008884
.. opcode:: JUMP_IF_TRUE_OR_POP (target)
1009885

Doc/library/functools.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,16 @@ The :mod:`functools` module defines the following functions:
160160
grow without bound.
161161

162162
If *typed* is set to true, function arguments of different types will be
163-
cached separately. For example, ``f(3)`` and ``f(3.0)`` will always be
164-
treated as distinct calls with distinct results. If *typed* is false,
165-
the implementation will usually but not always regard them as equivalent
166-
calls and only cache a single result.
163+
cached separately. If *typed* is false, the implementation will usually
164+
regard them as equivalent calls and only cache a single result. (Some
165+
types such as *str* and *int* may be cached separately even when *typed*
166+
is false.)
167+
168+
Note, type specificity applies only to the function's immediate arguments
169+
rather than their contents. The scalar arguments, ``Decimal(42)`` and
170+
``Fraction(42)`` are be treated as distinct calls with distinct results.
171+
In contrast, the tuple arguments ``('answer', Decimal(42))`` and
172+
``('answer', Fraction(42))`` are treated as equivalent.
167173

168174
The wrapped function is instrumented with a :func:`cache_parameters`
169175
function that returns a new :class:`dict` showing the values for *maxsize*

Doc/library/socket.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ Creating sockets
562562
The following functions all create :ref:`socket objects <socket-objects>`.
563563

564564

565-
.. function:: socket(family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None)
565+
.. class:: socket(family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None)
566566

567567
Create a new socket using the given address family, socket type and protocol
568568
number. The address family should be :const:`AF_INET` (the default),

Doc/using/configure.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ General Options
116116

117117
.. versionadded:: 3.10
118118

119+
.. cmdoption:: --with-pkg-config=[check|yes|no]
120+
121+
Whether configure should use :program:`pkg-config` to detect build
122+
dependencies.
123+
124+
* ``check`` (default): :program:`pkg-config` is optional
125+
* ``yes``: :program:`pkg-config` is mandatory
126+
* ``no``: configure does not use :program:`pkg-config` even when present
127+
128+
.. versionadded:: 3.11
129+
119130

120131
Install Options
121132
---------------

Doc/whatsnew/3.11.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ Optimizations
315315
CPython bytecode changes
316316
========================
317317

318+
* Replaced all numeric ``BINARY_*`` and ``INPLACE_*`` instructions with a single
319+
:opcode:`BINARY_OP` implementation.
320+
318321
* Added a new :opcode:`CALL_METHOD_KW` opcode. Calls a method in a similar
319322
fashion as :opcode:`CALL_METHOD`, but also supports keyword arguments. Works
320323
in tandem with :opcode:`LOAD_METHOD`.
@@ -329,6 +332,8 @@ CPython bytecode changes
329332
* Added :opcode:`COPY`, which pushes the *i*-th item to the top of the stack.
330333
The item is not removed from its original location.
331334

335+
* :opcode:`JUMP_IF_NOT_EXC_MATCH` no longer pops the active exception.
336+
332337

333338
Deprecated
334339
==========
@@ -528,6 +533,10 @@ Build Changes
528533
detected by :program:`configure`.
529534
(Contributed by Christian Heimes in :issue:`45763`.)
530535

536+
* Build dependencies for :mod:`dbm` are now detected by :program:`configure`.
537+
``libdb`` 3.x and 4.x are no longer supported.
538+
(Contributed by Christian Heimes in :issue:`45747`.)
539+
531540
C API Changes
532541
=============
533542

Include/cpython/import.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct _frozen {
3232
const char *name; /* ASCII encoded string */
3333
const unsigned char *code;
3434
int size;
35+
PyObject *(*get_code)(void);
3536
};
3637

3738
/* Embedding apps may change this pointer to point to their favorite

Include/internal/pycore_code.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ int _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *nam
267267
int _Py_Specialize_LoadGlobal(PyObject *globals, PyObject *builtins, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache);
268268
int _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, SpecializedCacheEntry *cache);
269269
int _Py_Specialize_BinarySubscr(PyObject *sub, PyObject *container, _Py_CODEUNIT *instr);
270-
int _Py_Specialize_BinaryAdd(PyObject *left, PyObject *right, _Py_CODEUNIT *instr);
271-
int _Py_Specialize_BinaryMultiply(PyObject *left, PyObject *right, _Py_CODEUNIT *instr);
272270
int _Py_Specialize_CallFunction(PyObject *callable, _Py_CODEUNIT *instr, int nargs, SpecializedCacheEntry *cache, PyObject *builtins);
271+
void _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
272+
SpecializedCacheEntry *cache);
273273

274274
#define PRINT_SPECIALIZATION_STATS 0
275275
#define PRINT_SPECIALIZATION_STATS_DETAILED 0

0 commit comments

Comments
 (0)