Skip to content

Commit 5df7949

Browse files
Merge branch 'main' into fix/fnmatch-filter-pathlike
2 parents e32415c + 1dd8e71 commit 5df7949

6 files changed

Lines changed: 57 additions & 15 deletions

File tree

‎Doc/builtins/stdtypes.rst‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,13 +2129,23 @@ expression support in the :mod:`re` module).
21292129
.. method:: str.capitalize()
21302130

21312131
Return a copy of the string with its first character capitalized and the
2132-
rest lowercased.
2132+
rest lowercased. For example:
2133+
2134+
.. doctest::
2135+
2136+
>>> 'PYTHON IS AMAZING'.capitalize()
2137+
'Python is amazing'
2138+
>>> 'Njemačka starts With a non-ASCII digraph'.capitalize()
2139+
'Njemačka starts with a non-ascii digraph'
2140+
2141+
See also :meth:`title`.
21332142

21342143
.. versionchanged:: 3.8
21352144
The first character is now put into titlecase rather than uppercase.
21362145
This means that characters like digraphs will only have their first
21372146
letter capitalized, instead of the full character.
21382147

2148+
21392149
.. method:: str.casefold()
21402150

21412151
Return a casefolded copy of the string. Casefolded strings may be used for
@@ -3137,7 +3147,7 @@ expression support in the :mod:`re` module).
31373147
>>> titlecase("they're bill's friends.")
31383148
"They're Bill's Friends."
31393149

3140-
See also :meth:`istitle`.
3150+
See also :meth:`istitle` and :meth:`capitalize`.
31413151

31423152

31433153
.. method:: str.translate(table, /)

‎Doc/library/collections.abc.rst‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ Collections Abstract Base Classes
111111

112112
The collections module offers the following :term:`ABCs <abstract base class>`:
113113

114+
The "Abstract Methods" column lists all required abstract methods,
115+
including those inherited from parent classes.
116+
114117
.. tabularcolumns:: |l|L|L|L|
115118

116119
============================== ====================== ======================= ====================================================
@@ -120,7 +123,8 @@ ABC Inherits from Abstract Methods Mi
120123
:class:`Hashable` [1]_ ``__hash__``
121124
:class:`Iterable` [1]_ [2]_ ``__iter__``
122125
:class:`Iterator` [1]_ :class:`Iterable` ``__next__`` ``__iter__``
123-
:class:`Reversible` [1]_ :class:`Iterable` ``__reversed__``
126+
:class:`Reversible` [1]_ :class:`Iterable` ``__iter__``,
127+
``__reversed__``
124128
:class:`Generator` [1]_ :class:`Iterator` ``send``, ``throw`` ``close``, ``__iter__``, ``__next__``
125129
:class:`Sized` [1]_ ``__len__``
126130
:class:`Callable` [1]_ ``__call__``
@@ -170,7 +174,8 @@ ABC Inherits from Abstract Methods Mi
170174
:class:`ValuesView` :class:`MappingView`, ``__contains__``, ``__iter__``
171175
:class:`Collection`
172176
:class:`Awaitable` [1]_ ``__await__``
173-
:class:`Coroutine` [1]_ :class:`Awaitable` ``send``, ``throw`` ``close``
177+
:class:`Coroutine` [1]_ :class:`Awaitable` ``__await__``, ``close``
178+
``send``, ``throw``
174179
:class:`AsyncIterable` [1]_ ``__aiter__``
175180
:class:`AsyncIterator` [1]_ :class:`AsyncIterable` ``__anext__`` ``__aiter__``
176181
:class:`AsyncGenerator` [1]_ :class:`AsyncIterator` ``asend``, ``athrow`` ``aclose``, ``__aiter__``, ``__anext__``

‎Doc/library/pdb.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ slightly different way:
214214

215215
.. awaitablefunction:: set_trace_async(*, header=None, commands=None)
216216

217-
async version of :func:`set_trace`. This function should be used inside an
218-
async function with :keyword:`await`.
217+
Asynchronous version of :func:`set_trace`. This function should be used inside
218+
a :term:`coroutine function` with :keyword:`await`. For instance:
219219

220220
.. code-block:: python
221221

‎Lib/test/test_long.py‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,33 @@ def test_division(self):
204204
self.check_division(710031681576388032, 26769404391308)
205205
self.check_division(1933622614268221, 30212853348836)
206206

207-
207+
@support.requires_IEEE_754
208+
def test_intradigit_shift(self):
209+
# Unit tests for v_lshift and v_rshift in longobject.c.
210+
# These two functions are not used by Python << and >>,
211+
# exercise them via float conversion and true division.
212+
213+
# Full limb values.
214+
two_limbs = (1 << (2 * SHIFT)) - 1
215+
three_limbs = (1 << (3 * SHIFT)) - 1
216+
four_limbs = (1 << (4 * SHIFT)) - 1
217+
# Multi-limb (not compact) but bit_length() still <= 55.
218+
bits50 = (1 << 50) - 1
219+
220+
# _PyLong_Frexp (float(n)):
221+
# v_lshift if n.bit_length() <= 55, else v_rshift.
222+
self.check_float_conversion(bits50)
223+
self.check_float_conversion(two_limbs)
224+
self.check_float_conversion(four_limbs)
225+
self.check_float_conversion(10**40)
226+
227+
# long_true_divide (a / b):
228+
# - (a.bit_length() - b.bit_length()) <= 55 => v_lshift,
229+
# - (a.bit_length() - b.bit_length()) > 55 => v_rshift.
230+
self.check_truediv(three_limbs, two_limbs)
231+
self.check_truediv(four_limbs, two_limbs)
232+
self.check_truediv(four_limbs, three_limbs)
233+
self.check_truediv(10**40, 10**20)
208234

209235
def test_karatsuba(self):
210236
digits = list(range(1, 5)) + list(range(KARATSUBA_CUTOFF,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Speed up :func:`float` conversion and true division of large :class:`int` values.

‎Objects/longobject.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,15 +1905,15 @@ static digit
19051905
v_lshift(digit *z, digit *a, Py_ssize_t m, int d)
19061906
{
19071907
Py_ssize_t i;
1908-
digit carry = 0;
1908+
twodigits carry = 0;
19091909

19101910
assert(0 <= d && d < PyLong_SHIFT);
19111911
for (i=0; i < m; i++) {
19121912
twodigits acc = (twodigits)a[i] << d | carry;
19131913
z[i] = (digit)acc & PyLong_MASK;
1914-
carry = (digit)(acc >> PyLong_SHIFT);
1914+
carry = acc >> PyLong_SHIFT;
19151915
}
1916-
return carry;
1916+
return (digit)carry;
19171917
}
19181918

19191919
/* Shift digit vector a[0:m] d bits right, with 0 <= d < PyLong_SHIFT. Put
@@ -1923,16 +1923,16 @@ static digit
19231923
v_rshift(digit *z, digit *a, Py_ssize_t m, int d)
19241924
{
19251925
Py_ssize_t i;
1926-
digit carry = 0;
1927-
digit mask = ((digit)1 << d) - 1U;
1926+
twodigits carry = 0;
1927+
twodigits mask = ((twodigits)1 << d) - 1U;
19281928

19291929
assert(0 <= d && d < PyLong_SHIFT);
19301930
for (i=m; i-- > 0;) {
1931-
twodigits acc = (twodigits)carry << PyLong_SHIFT | a[i];
1932-
carry = (digit)acc & mask;
1931+
twodigits acc = carry << PyLong_SHIFT | a[i];
1932+
carry = acc & mask;
19331933
z[i] = (digit)(acc >> d);
19341934
}
1935-
return carry;
1935+
return (digit)carry;
19361936
}
19371937

19381938
/* Divide long pin, w/ size digits, by non-zero digit n, storing quotient

0 commit comments

Comments
 (0)