Skip to content

Commit 9c09fc4

Browse files
committed
Merge branch 'main' into pythongh-73435-pathlib-match-recursive
2 parents 559787d + ae00b81 commit 9c09fc4

File tree

525 files changed

+8361
-25173
lines changed

Some content is hidden

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

525 files changed

+8361
-25173
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Include/pytime.h @pganssle @abalkin
9797
/Tools/peg_generator/ @pablogsal @lysnikolaou
9898
/Lib/test/test_peg_generator/ @pablogsal @lysnikolaou
9999
/Grammar/python.gram @pablogsal @lysnikolaou
100+
/Lib/tokenize.py @pablogsal @lysnikolaou
101+
/Lib/test/test_tokenize.py @pablogsal @lysnikolaou
100102

101103
# AST
102104
Python/ast.c @isidentical

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
push:
99
branches:
1010
- 'main'
11+
- '3.12'
1112
- '3.11'
1213
- '3.10'
1314
- '3.9'
@@ -16,6 +17,7 @@ on:
1617
pull_request:
1718
branches:
1819
- 'main'
20+
- '3.12'
1921
- '3.11'
2022
- '3.10'
2123
- '3.9'
@@ -368,6 +370,14 @@ jobs:
368370
echo "HYPOVENV=${VENV_LOC}" >> $GITHUB_ENV
369371
echo "VENV_PYTHON=${VENV_PYTHON}" >> $GITHUB_ENV
370372
./python -m venv $VENV_LOC && $VENV_PYTHON -m pip install -U hypothesis
373+
- name: 'Restore Hypothesis database'
374+
id: cache-hypothesis-database
375+
uses: actions/cache@v3
376+
with:
377+
path: ./hypothesis
378+
key: hypothesis-database-${{ github.head_ref || github.run_id }}
379+
restore-keys: |
380+
- hypothesis-database-
371381
- name: "Run tests"
372382
working-directory: ${{ env.CPYTHON_BUILDDIR }}
373383
run: |
@@ -388,6 +398,11 @@ jobs:
388398
-x test_subprocess \
389399
-x test_signal \
390400
-x test_sysconfig
401+
- uses: actions/upload-artifact@v3
402+
if: always()
403+
with:
404+
name: hypothesis-example-db
405+
path: .hypothesis/examples/
391406

392407

393408
build_asan:

.github/workflows/doc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
#push:
66
# branches:
77
# - 'main'
8+
# - '3.12'
89
# - '3.11'
910
# - '3.10'
1011
# - '3.9'
@@ -15,6 +16,7 @@ on:
1516
pull_request:
1617
branches:
1718
- 'main'
19+
- '3.12'
1820
- '3.11'
1921
- '3.10'
2022
- '3.9'

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
*.gc??
2424
*.profclang?
2525
*.profraw
26+
# Copies of binaries before BOLT optimizations.
27+
*.prebolt
28+
# BOLT profile data.
29+
*.fdata
2630
*.dyn
2731
.gdb_history
2832
.purify
@@ -57,7 +61,6 @@ Doc/.venv/
5761
Doc/env/
5862
Doc/.env/
5963
Include/pydtrace_probes.h
60-
Lib/lib2to3/*.pickle
6164
Lib/site-packages/*
6265
!Lib/site-packages/README.txt
6366
Lib/test/data/*
@@ -124,6 +127,7 @@ Tools/unicode/data/
124127
/platform
125128
/profile-clean-stamp
126129
/profile-run-stamp
130+
/profile-bolt-stamp
127131
/Python/deepfreeze/*.c
128132
/pybuilddir.txt
129133
/pyconfig.h

Doc/c-api/long.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,27 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
322322
with :c:func:`PyLong_FromVoidPtr`.
323323
324324
Returns ``NULL`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
325+
326+
327+
.. c:function:: int PyUnstable_Long_IsCompact(const PyLongObject* op)
328+
329+
Return 1 if *op* is compact, 0 otherwise.
330+
331+
This function makes it possible for performance-critical code to implement
332+
a “fast path” for small integers. For compact values use
333+
:c:func:`PyUnstable_Long_CompactValue`; for others fall back to a
334+
:c:func:`PyLong_As* <PyLong_AsSize_t>` function or
335+
:c:func:`calling <PyObject_CallMethod>` :meth:`int.to_bytes`.
336+
337+
The speedup is expected to be negligible for most users.
338+
339+
Exactly what values are considered compact is an implementation detail
340+
and is subject to change.
341+
342+
.. c:function:: Py_ssize_t PyUnstable_Long_CompactValue(const PyLongObject* op)
343+
344+
If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`,
345+
return its value.
346+
347+
Otherwise, the return value is undefined.
348+

Doc/c-api/perfmaps.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. highlight:: c
2+
3+
.. _perfmaps:
4+
5+
Support for Perf Maps
6+
----------------------
7+
8+
On supported platforms (as of this writing, only Linux), the runtime can take
9+
advantage of *perf map files* to make Python functions visible to an external
10+
profiling tool (such as `perf <https://perf.wiki.kernel.org/index.php/Main_Page>`_).
11+
A running process may create a file in the ``/tmp`` directory, which contains entries
12+
that can map a section of executable code to a name. This interface is described in the
13+
`documentation of the Linux Perf tool <https://git.kernel.org/pub/scm/linux/
14+
kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/jit-interface.txt>`_.
15+
16+
In Python, these helper APIs can be used by libraries and features that rely
17+
on generating machine code on the fly.
18+
19+
Note that holding the Global Interpreter Lock (GIL) is not required for these APIs.
20+
21+
.. c:function:: int PyUnstable_PerfMapState_Init(void)
22+
23+
Open the ``/tmp/perf-$pid.map`` file, unless it's already opened, and create
24+
a lock to ensure thread-safe writes to the file (provided the writes are
25+
done through :c:func:`PyUnstable_WritePerfMapEntry`). Normally, there's no need
26+
to call this explicitly; just use :c:func:`PyUnstable_WritePerfMapEntry`
27+
and it will initialize the state on first call.
28+
29+
Returns ``0`` on success, ``-1`` on failure to create/open the perf map file,
30+
or ``-2`` on failure to create a lock. Check ``errno`` for more information
31+
about the cause of a failure.
32+
33+
.. c:function:: int PyUnstable_WritePerfMapEntry(const void *code_addr, unsigned int code_size, const char *entry_name)
34+
35+
Write one single entry to the ``/tmp/perf-$pid.map`` file. This function is
36+
thread safe. Here is what an example entry looks like::
37+
38+
# address size name
39+
7f3529fcf759 b py::bar:/run/t.py
40+
41+
Will call :c:func:`PyUnstable_PerfMapState_Init` before writing the entry, if
42+
the perf map file is not already opened. Returns ``0`` on success, or the
43+
same error codes as :c:func:`PyUnstable_PerfMapState_Init` on failure.
44+
45+
.. c:function:: void PyUnstable_PerfMapState_Fini(void)
46+
47+
Close the perf map file opened by :c:func:`PyUnstable_PerfMapState_Init`.
48+
This is called by the runtime itself during interpreter shut-down. In
49+
general, there shouldn't be a reason to explicitly call this, except to
50+
handle specific scenarios such as forking.

0 commit comments

Comments
 (0)