Skip to content

Commit 7bc9fa7

Browse files
Merge branch 'main' into jit-yml-cleanup
2 parents 68e6cff + cfeede8 commit 7bc9fa7

File tree

8 files changed

+60
-23
lines changed

8 files changed

+60
-23
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.14.10
3+
rev: v0.15.0
44
hooks:
55
- id: ruff-check
66
name: Run Ruff (lint) on Apple/
@@ -52,14 +52,14 @@ repos:
5252
files: ^Tools/wasm/
5353

5454
- repo: https://github.com/psf/black-pre-commit-mirror
55-
rev: 25.12.0
55+
rev: 26.1.0
5656
hooks:
5757
- id: black
5858
name: Run Black on Tools/jit/
5959
files: ^Tools/jit/
6060

6161
- repo: https://github.com/Lucas-C/pre-commit-hooks
62-
rev: v1.5.5
62+
rev: v1.5.6
6363
hooks:
6464
- id: remove-tabs
6565
types: [python]
@@ -83,19 +83,19 @@ repos:
8383
files: '^\.github/CODEOWNERS|\.(gram)$'
8484

8585
- repo: https://github.com/python-jsonschema/check-jsonschema
86-
rev: 0.36.0
86+
rev: 0.36.1
8787
hooks:
8888
- id: check-dependabot
8989
- id: check-github-workflows
9090
- id: check-readthedocs
9191

9292
- repo: https://github.com/rhysd/actionlint
93-
rev: v1.7.9
93+
rev: v1.7.10
9494
hooks:
9595
- id: actionlint
9696

9797
- repo: https://github.com/woodruffw/zizmor-pre-commit
98-
rev: v1.19.0
98+
rev: v1.22.0
9999
hooks:
100100
- id: zizmor
101101

Doc/library/enum.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ Utilities and Decorators
10531053
>>> enum.bin(~10) # ~10 is -11
10541054
'0b1 0101'
10551055

1056-
.. versionadded:: 3.10
1056+
.. versionadded:: 3.11
10571057

10581058
---------------
10591059

Doc/library/secrets.rst

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,44 @@ The :mod:`!secrets` module provides functions for generating secure
6262
tokens, suitable for applications such as password resets,
6363
hard-to-guess URLs, and similar.
6464

65-
.. function:: token_bytes([nbytes=None])
65+
.. function:: token_bytes(nbytes=None)
6666

6767
Return a random byte string containing *nbytes* number of bytes.
68-
If *nbytes* is ``None`` or not supplied, a reasonable default is
69-
used.
68+
69+
If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY`
70+
is used instead.
7071

7172
.. doctest::
7273

73-
>>> token_bytes(16) #doctest:+SKIP
74+
>>> token_bytes(16) # doctest: +SKIP
7475
b'\xebr\x17D*t\xae\xd4\xe3S\xb6\xe2\xebP1\x8b'
7576

7677

77-
.. function:: token_hex([nbytes=None])
78+
.. function:: token_hex(nbytes=None)
7879

7980
Return a random text string, in hexadecimal. The string has *nbytes*
80-
random bytes, each byte converted to two hex digits. If *nbytes* is
81-
``None`` or not supplied, a reasonable default is used.
81+
random bytes, each byte converted to two hex digits.
82+
83+
If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY`
84+
is used instead.
8285

8386
.. doctest::
8487

85-
>>> token_hex(16) #doctest:+SKIP
88+
>>> token_hex(16) # doctest: +SKIP
8689
'f9bf78b9a18ce6d46a0cd2b0b86df9da'
8790

88-
.. function:: token_urlsafe([nbytes=None])
91+
.. function:: token_urlsafe(nbytes=None)
8992

9093
Return a random URL-safe text string, containing *nbytes* random
9194
bytes. The text is Base64 encoded, so on average each byte results
92-
in approximately 1.3 characters. If *nbytes* is ``None`` or not
93-
supplied, a reasonable default is used.
95+
in approximately 1.3 characters.
96+
97+
If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY`
98+
is used instead.
9499

95100
.. doctest::
96101

97-
>>> token_urlsafe(16) #doctest:+SKIP
102+
>>> token_urlsafe(16) # doctest: +SKIP
98103
'Drmhze6EPcv0fN_81Bj-nA'
99104

100105

@@ -115,11 +120,13 @@ argument to the various ``token_*`` functions. That argument is taken
115120
as the number of bytes of randomness to use.
116121

117122
Otherwise, if no argument is provided, or if the argument is ``None``,
118-
the ``token_*`` functions will use a reasonable default instead.
123+
the ``token_*`` functions uses :const:`DEFAULT_ENTROPY` instead.
119124

120-
.. note::
125+
.. data:: DEFAULT_ENTROPY
126+
127+
Default number of bytes of randomness used by the ``token_*`` functions.
121128

122-
That default is subject to change at any time, including during
129+
The exact value is subject to change at any time, including during
123130
maintenance releases.
124131

125132

Lib/test/test_capi/test_opt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,23 @@ def f(n):
19861986
self.assertNotIn("_GUARD_NOS_TUPLE", uops)
19871987
self.assertIn("_BINARY_OP_SUBSCR_TUPLE_INT", uops)
19881988

1989+
def test_remove_guard_for_known_type_slice(self):
1990+
def f(n):
1991+
x = 0
1992+
for _ in range(n):
1993+
l = [1, 2, 3]
1994+
slice_obj = slice(0, 1)
1995+
x += l[slice_obj][0] # guarded
1996+
x += l[slice_obj][0] # unguarded
1997+
return x
1998+
res, ex = self._run_with_optimizer(f, TIER2_THRESHOLD)
1999+
self.assertEqual(res, TIER2_THRESHOLD * 2)
2000+
uops = get_opnames(ex)
2001+
2002+
count = count_ops(ex, "_GUARD_TOS_SLICE")
2003+
self.assertEqual(count, 1)
2004+
self.assertIn("_BINARY_OP_SUBSCR_LIST_INT", uops)
2005+
19892006
def test_remove_guard_for_tuple_bounds_check(self):
19902007
def f(n):
19912008
x = 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Optimise ``_GUARD_TOS_SLICE`` in the JIT.

Python/optimizer_bytecodes.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,13 @@ dummy_func(void) {
13741374
}
13751375
}
13761376

1377+
op(_GUARD_TOS_SLICE, (tos -- tos)) {
1378+
if (sym_matches_type(tos, &PySlice_Type)) {
1379+
ADD_OP(_NOP, 0, 0);
1380+
}
1381+
sym_set_type(tos, &PySlice_Type);
1382+
}
1383+
13771384
op(_GUARD_NOS_NULL, (null, unused -- null, unused)) {
13781385
if (sym_is_null(null)) {
13791386
ADD_OP(_NOP, 0, 0);

Python/optimizer_cases.c.h

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

Tools/jit/_llvm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import _targets
1212

13-
1413
_LLVM_VERSION = "21"
1514
_EXTERNALS_LLVM_TAG = "llvm-21.1.4.0"
1615

0 commit comments

Comments
 (0)