Commit Graph

1244 Commits

Author SHA1 Message Date
Victor Stinner f9d47fed9f
gh-119853: Add Include/refcount.h to projects (#119860) 2024-05-31 21:21:30 +02:00
Sam Gross 1c04c63ced
gh-119729: Use 't' in pkg-config file name for free-threaded build (#119738)
For example, the free-threaded build now generates
`lib/pkgconfig/python-3.13t.pc` and the debug build generates
`lib/pkgconfig/python-3.13d.pc`.
2024-05-30 13:48:28 -04:00
Matthias Görgens 18c1a8d3a8
gh-97588: Align ctypes struct layout to GCC/MSVC (GH-97702)
Structure layout, and especially bitfields, sometimes resulted in clearly
wrong behaviour like overlapping fields. This fixes

Co-authored-by: Gregory P. Smith <gps@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-05-29 12:02:53 +02:00
Erlend E. Aasland 606be66362
gh-119538: Add missing expat build dependencies (#119647)
xmltok_impl.c and xmltok_ns.c are _included_ in xmltok.c by the C
pre-processor.
2024-05-28 22:05:19 +02:00
Victor Stinner 0518edc170
gh-119396: Optimize unicode_repr() (#119617)
Use stringlib to specialize unicode_repr() for each string kind
(UCS1, UCS2, UCS4).

Benchmark:

+-------------------------------------+---------+----------------------+
| Benchmark                           | ref     | change2              |
+=====================================+=========+======================+
| repr('abc')                         | 100 ns  | 103 ns: 1.02x slower |
+-------------------------------------+---------+----------------------+
| repr('a' * 100)                     | 369 ns  | 369 ns: 1.00x slower |
+-------------------------------------+---------+----------------------+
| repr(('a' + squote) * 100)          | 1.21 us | 946 ns: 1.27x faster |
+-------------------------------------+---------+----------------------+
| repr(('a' + nl) * 100)              | 1.23 us | 907 ns: 1.36x faster |
+-------------------------------------+---------+----------------------+
| repr(dquote + ('a' + squote) * 100) | 1.08 us | 858 ns: 1.25x faster |
+-------------------------------------+---------+----------------------+
| Geometric mean                      | (ref)   | 1.16x faster         |
+-------------------------------------+---------+----------------------+
2024-05-28 18:05:20 +02:00
Eugene Triguba f49df4f486
gh-119306: Break up _pyrepl tests (#119307) 2024-05-21 18:44:09 +02:00
John Sirois 49258efada
gh-118107: Fix zipimporter ZIP64 handling. (GH-118108)
Add missing import to code that handles too large files and offsets.
Use list, not tuple, for a mutable sequence.

Add tests to prevent similar mistakes.

---------

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-05-07 09:23:27 +02:00
Russell Keith-Magee 1506d5adc4
Set a DerivedData path for iOS test builds. (GH-118621) 2024-05-05 23:58:14 -04:00
Russell Keith-Magee dd37e85518
Correct timing sensitivity in iOS testing Makefile target. (GH-118620) 2024-05-05 22:34:59 -04:00
Pablo Galindo Salgado f27f8c790a
gh-111201: A new Python REPL (GH-111567)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-05-05 21:32:23 +02:00
Pablo Galindo Salgado 1b22d801b8
gh-118518: Allow perf to work without frame pointers (#112254) 2024-05-05 03:07:29 +02:00
Irit Katriel 85af789961
gh-111997: C-API for signalling monitoring events (#116413) 2024-05-04 08:23:50 +00:00
Ken Jin dc6b12d1b2
gh-117139: Add header for tagged pointers (GH-118330)
---------

Co-authored-by: Sam Gross <655866+colesbury@users.noreply.github.com>
2024-05-01 04:46:13 +08:00
Serhiy Storchaka c0eaa232f6
gh-117860: Add tests for resolving names when import rebind names (GH-118176)
Add tests for "import", pkgutil.resolve_name() and unittest.mock.path()
for cases when "import a.b as x" and "from a import b as x" give
different results.
2024-04-30 17:23:44 +03:00
Eric Snow 03e3e31723
gh-76785: Rename _xxsubinterpreters to _interpreters (gh-117791)
See https://discuss.python.org/t/pep-734-multiple-interpreters-in-the-stdlib/41147/26.
2024-04-24 16:18:24 +00:00
Yichen Yan e17cd1fbfd
gh-116984: Install mimalloc headers (#116985)
- Install mimalloc header only when enabled
- Rename WITH_MIMALLOC to INSTALL_MIMALLOC
2024-04-23 09:56:00 +02:00
Dino Viehland 07525c9a85
gh-116818: Make `sys.settrace`, `sys.setprofile`, and monitoring thread-safe (#116775)
Makes sys.settrace, sys.setprofile, and monitoring generally thread-safe.

Mostly uses a stop-the-world approach and synchronization around the code object's _co_instrumentation_version.  There may be a little bit of extra synchronization around the monitoring data that's required to be TSAN clean.
2024-04-19 14:47:42 -07:00
Irit Katriel 04697bcfaf
gh-117494: extract the Instruction Sequence data structure into a separate file (#117496) 2024-04-04 15:47:26 +00:00
Guido van Rossum 060a96f1a9
gh-116968: Reimplement Tier 2 counters (#117144)
Introduce a unified 16-bit backoff counter type (``_Py_BackoffCounter``),
shared between the Tier 1 adaptive specializer and the Tier 2 optimizer. The
API used for adaptive specialization counters is changed but the behavior is
(supposed to be) identical.

The behavior of the Tier 2 counters is changed:
- There are no longer dynamic thresholds (we never varied these).
- All counters now use the same exponential backoff.
- The counter for ``JUMP_BACKWARD`` starts counting down from 16.
- The ``temperature`` in side exits starts counting down from 64.
2024-04-04 15:03:27 +00:00
Eric Snow f341d6017d
gh-76785: Add PyInterpreterConfig Helpers (gh-117170)
These helpers make it easier to customize and inspect the config used to initialize interpreters.  This is especially valuable in our tests.  I found inspiration from the PyConfig API for the PyInterpreterConfig dict conversion stuff.  As part of this PR I've also added a bunch of tests.
2024-04-02 20:35:52 +00:00
Sam Gross 19c1dd60c5
gh-117323: Make `cell` thread-safe in free-threaded builds (#117330)
Use critical sections to lock around accesses to cell contents. The critical sections are no-ops in the default (with GIL) build.
2024-03-29 13:35:43 -04:00
Russell Keith-Magee f006338017
gh-114099: Additions to standard library to support iOS (GH-117052)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
Co-authored-by: Ned Deily <nad@python.org>
2024-03-28 03:59:33 -04:00
Eric Snow 617158e078
gh-76785: Drop PyInterpreterID_Type (gh-117101)
I added it quite a while ago as a strategy for managing interpreter lifetimes relative to the PEP 554 (now 734) implementation.  Relatively recently I refactored that implementation to no longer rely on InterpreterID objects.  Thus now I'm removing it.
2024-03-21 17:15:02 +00:00
Jason R. Coombs 667294d5b2
gh-117089: Apply changes from importlib_metadata 7.1.0 (#117094)
* Apply changes from importlib_metadata 7.1.0

* Include the data sources in the makefile (even though they're not needed)
2024-03-20 23:01:24 -04:00
Jason R. Coombs 8ad8898420
gh-117089: Move importlib.metadata tests to their own package (#117092)
* Ensure importlib.metadata tests do not leak references in sys.modules.

* Move importlib.metadata tests to their own package for easier syncing with importlib_metadata.

* Update owners and makefile for new directories.

* Add blurb
2024-03-20 17:11:00 -04:00
Victor Stinner 3cac2af5ec
gh-116417: Move limited C API long.c tests to _testlimitedcapi (#117001)
* Split long.c tests of _testcapi into two parts: limited C API tests
  in _testlimitedcapi and non-limited C API tests in _testcapi.
* Move testcapi_long.h from Modules/_testcapi/ to
  Modules/_testlimitedcapi/.
* Add MODULE__TESTLIMITEDCAPI_DEPS to Makefile.pre.in.
2024-03-19 14:04:23 +00:00
Victor Stinner 590a26010d
gh-116869: Add test_cext test: build a C extension (#116954) 2024-03-18 20:15:20 +01:00
Guido van Rossum 9c7b3688e6
gh-108716: Cleanup remaining deepfreeze infrastructure (#116919)
Keep Tools/build/deepfreeze.py around (we may repurpose it for deepfreezing non-code objects),
and keep basic "clean" targets that remove the output of former deep-freeze activities,
to keep the build directories of current devs clean.
2024-03-18 11:13:11 -07:00
Skip Montanaro d9ccde28c4
gh-106259: Add minimal help target to Makefile (#106260)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-03-07 18:21:28 +01:00
Guido van Rossum 68157446aa
Parallelize regen-cases (#116446)
This makes a huge difference when using `make -j regen-cases`.
2024-03-07 07:25:24 -08:00
Russell Keith-Magee b33980a2e3
gh-114099 - Add iOS testbed, plus Makefile target to invoke it. (gh-115930) 2024-03-06 23:24:52 -05:00
Sergey B Kirpichev ea1b1c579f
gh-108562: Revert enabling -fstrict-overflow for libmpdec (GH-116302)
gh-108562: partial reversion of pr114751

Reverts -fstrict-overflow for libmpdec
2024-03-04 18:07:24 +01:00
Sergey B Kirpichev 002a5948fc
gh-108562: Fix compiler warnings for libmpdec (#114751)
If awailable, enable -fstrict-overflow for libmpdec. Also
shut off false positive warnings (-Warray-bounds).

The later was backported from mpdecimal-4.0.0.
2024-03-03 08:25:39 +01:00
Malcolm Smith fa1d675309
gh-71052: Fix several Android build issues (#115955)
This change is part of the work on PEP-738: Adding Android as a 
supported platform.

* Remove the "1.0" suffix from libpython's filename on Android, which 
  would prevent Gradle from packaging it into an app. 
* Simplify the build command in the Makefile so that libpython always 
  gets given an SONAME with the `-Wl-h` argument, even if the SONAME is
  identical to the actual filename.
* Disable a number of functions on Android which can be compiled and 
  linked against, but always fail at runtime. As a result, the native
  _multiprocessing module is no longer built for Android.
* gh-115390 (bee7bb331) added some pre-determined results to the 
  configure script for things that can't be autodetected when
  cross-compiling; this change adds Android to these where appropriate.
* Add a couple more pre-determined results for Android, and making them 
  cover iOS as well. This means the --enable-ipv6 configure option will 
  no longer be required on either platform.
2024-02-29 22:58:20 +01:00
Mark Shannon 10fbcd6c5d
GH-115816: Make tier2 optimizer symbols testable, and add a few tests. (GH-115953) 2024-02-27 10:51:26 +00:00
Guido van Rossum c0fdfba7ff
Rename tier 2 redundancy eliminator to optimizer (#115888)
The original name is just too much of a mouthful.
2024-02-26 08:42:53 -08:00
Russell Keith-Magee bee7bb3310
gh-114099: Add configure and Makefile targets to support iOS compilation. (GH-115390) 2024-02-25 20:21:10 -05:00
Seth Michael Larson c6a47de709
gh-115663: Remove 'regen-sbom' from the 'regen-all' target (#115790) 2024-02-22 15:42:26 +02:00
Malcolm Smith 7f5e3f04f8
gh-111225: Link extension modules against libpython on Android (#115780)
Part of the work on PEP 738: Adding Android as a supported platform.

* Rename the LIBPYTHON variable to MODULE_LDFLAGS, to more accurately 
  reflect its purpose.
* Edit makesetup to use MODULE_LDFLAGS when linking extension modules.
* Edit the Makefile so that extension modules depend on libpython on 
  Android and Cygwin.
* Restore `-fPIC` on Android. It was removed several years ago with a 
  note that the toolchain used it automatically, but this is no longer
  the case. Omitting it causes all linker commands to fail with an error
  like `relocation R_AARCH64_ADR_PREL_PG_HI21 cannot be used against
  symbol '_Py_FalseStruct'; recompile with -fPIC`.
2024-02-21 23:18:57 +00:00
Russell Keith-Magee 074bbec9c4
gh-115737: Correct libpython install name for macOS shared library builds. (gh-115750) 2024-02-21 04:11:04 -05:00
Sam Gross 5903190727
gh-115103: Implement delayed memory reclamation (QSBR) (#115180)
This adds a safe memory reclamation scheme based on FreeBSD's "GUS" and
quiescent state based reclamation (QSBR). The API provides a mechanism
for callers to detect when it is safe to free memory that may be
concurrently accessed by readers.
2024-02-16 15:25:19 -05:00
mpage a95b1a56bb
gh-115041: Add wrappers that are atomic only in free-threaded builds (#115046)
These are intended to be used in places where atomics are required in
free-threaded builds but not in the default build. We don't want to
introduce the potential performance overhead of an atomic operation in the
default build.
2024-02-14 15:15:05 -05:00
T. Wouters 518af37eb5
gh-115421: Update the list of installed test subdirectories. (#115422)
Update the list of installed test subdirectories with all newly added
subdirectories of Lib/test, so that the tests in those directories are
properly installed.
2024-02-14 00:58:49 +01:00
Eric Snow 514b1c91b8
gh-76785: Improved Subinterpreters Compatibility with 3.12 (gh-115424)
For the most part, these changes make is substantially easier to backport subinterpreter-related code to 3.12, especially the related modules (e.g. _xxsubinterpreters). The main motivation is to support releasing a PyPI package with the 3.13 capabilities compiled for 3.12.

A lot of the changes here involve either hiding details behind macros/functions or splitting up some files.
2024-02-13 14:56:49 -07:00
Ken Jin 7cce857622
gh-114058: Foundations of the Tier2 redundancy eliminator (GH-115085)
---------

Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
Co-authored-by: Jules <57632293+JuliaPoo@users.noreply.github.com>
Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com>
2024-02-13 21:24:48 +08:00
Nikita Sobolev ccc76c3e88
gh-108303: Move all `pydoc` related test files to new `test.test_pydoc` package (#114506) 2024-02-13 11:40:40 +01:00
Russell Keith-Magee 2f0778675a
gh-114099: Refactor configure and Makefile to accomodate non-macOS frameworks (#115120)
Part of the PEP 730 work to add iOS support.

This change lays the groundwork for introducing iOS/tvOS/watchOS 
frameworks; it includes the structural refactoring needed so that iOS
branches can be added into in a subsequent PR.

Summary of changes:
* Updates config.sub to the 2024-01-01 release. This is the "as 
  released" version of config.sub.
* Adds a RESSRCDIR variable to allow sharing of macOS and iOS Makefile 
  steps.
* Adds an INSTALLTARGETS variable so platforms can customise which
  targets are actually installed. This will be used to exclude certain
  targets (e.g., binaries, manfiles) from iOS framework installs.
* Adds a PYTHONFRAMEWORKINSTALLNAMEPREFIX variable; this is used as
  the install name for the library. This is needed to allow for iOS
  frameworks to specify an @rpath-based install name.
* Evaluates MACHDEP earlier in the configure process so that
  ac_sys_system is available.
* Modifies _PYTHON_HOST_PLATFORM evaluation for cross-platform builds
  so that the CPU architecture is differentiated from the host
  identifier. This will be used to generate a _PYTHON_HOST_PLATFORM
  definition that includes ABI information, not just CPU architecture.
* Differentiates between SOABI_PLATFORM and PLATFORM_TRIPLET.
  SOABI_PLATFORM is used in binary module names, and includes the ABI,
  but not the OS or CPU architecture (e.g.,
  math.cpython-313-iphonesimulator.dylib). PLATFORM_TRIPLET is used
  as the sys._multiarch value, and on iOS will contains the ABI and
  architecture (e.g., iphoneos-arm64). This differentiation hasn't
  historically been needed because while macOS is a multiarch platform,
  it uses a bare darwin as PLATFORM_TRIPLE.
* Removes the use of the deprecated -Wl,-single_module flag when
  compiling macOS frameworks.
* Some whitespace normalisation where there was a mix of spaces and tabs 
  in a single block.
2024-02-13 00:10:24 +01:00
Sam Gross a3af3cb4f4
gh-110481: Implement inter-thread queue for biased reference counting (#114824)
Biased reference counting maintains two refcount fields in each object:
`ob_ref_local` and `ob_ref_shared`. The true refcount is the sum of these two
fields. In some cases, when refcounting operations are split across threads,
the ob_ref_shared field can be negative (although the total refcount must be
at least zero). In this case, the thread that decremented the refcount
requests that the owning thread give up ownership and merge the refcount
fields.
2024-02-09 17:08:32 -05:00
Skip Montanaro 2afc7182e6
gh-114505: Add missing header file dependencies (#114513)
Also move PYTHON_HEADERS up and make _testembed.o depend on it.
2024-02-07 08:50:24 +00:00
Zachary Ware 1032326fe4
gh-114883: Fix Makefile dependency tree for non-jit builds (GH-114884) 2024-02-03 23:16:03 +00:00