Commit Graph

5542 Commits

Author SHA1 Message Date
Savannah Ostrowski 65f1237098
GH-123516: Improve JIT memory consumption by invalidating cold executors (GH-124443)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-27 00:35:42 +00:00
neonene d7248cdbc3
gh-124153: Remove `_PyType_GetModuleByDef2` private function (GH-124261)
Thank you!
2024-09-26 18:21:11 +02:00
Jason Fried 46f5cbca4c
gh-119333: get interp from tstate for PyContext watchers(#124444)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-09-26 05:26:23 +00:00
Nice Zombies 9968caa0cc
gh-41431: Add `datetime.time.strptime()` and `datetime.date.strptime()` (#120752)
* Python implementation

* C implementation

* Test `date.strptime`

* Test `time.strptime`

* 📜🤖 Added by blurb_it.

* Update whatsnew

* Update documentation

* Add leap year note

* Update 2024-06-19-19-53-42.gh-issue-41431.gnkUc5.rst

* Apply suggestions from code review

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Remove parentheses

* Use helper function

* Remove bad return

* Link to github issue

* Fix directive

* Apply suggestions from code review

Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>

* Fix test cases

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2024-09-25 14:43:58 -07:00
Raymond Hettinger 909c6f7189
gh-123884 Tee of tee was not producing n independent iterators (gh-124490) 2024-09-25 13:38:05 -07:00
Irit Katriel 78aeb38f7d
gh-124285: Fix bug where bool() is called multiple times for the same part of a boolean expression (#124394) 2024-09-25 15:51:25 +01:00
Sam Gross f4997bb3ac
gh-123923: Defer refcounting for `f_funcobj` in `_PyInterpreterFrame` (#124026)
Use a `_PyStackRef` and defer the reference to `f_funcobj` when
possible. This avoids some reference count contention in the common case
of executing the same code object from multiple threads concurrently in
the free-threaded build.
2024-09-24 20:08:18 +00:00
Victor Stinner 9d344fafc4
gh-124127: Make Py_REFCNT() opaque in limited C API 3.14 (#124128) 2024-09-24 08:42:58 +02:00
Jason Fried d87482bc4e
gh-119333: Add C api to have contextvar enter/exit callbacks (#119335)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-09-23 20:40:17 -07:00
Donghee Na ad7c778546
gh-123990: Good bye WITH_FREELISTS macro (gh-124358) 2024-09-24 01:28:59 +00:00
neonene d9d5b3d2ef
gh-124344: Make `_PyObject_IS_GC()` use underscored `PyType_IS_GC()` (#124349)
move up _PyType_IS_GC and use it
2024-09-23 21:14:15 +02:00
Mark Shannon c87b0e4a46
GH-124284: Add stats for refcount operations on immortal objects (GH-124288) 2024-09-23 19:10:55 +01:00
Sam James 0e89f7abd4
GH-113655: Lower the C recursion limit for HPPA, PPC64 and SPARC (#124264)
Lower the C recursion limit for HPPA, PPC64 and SPARC, as they use
relatively large stack frames that cause e.g. `test_descr` to hit
a stack overflow.  According to quick testing, it seems that values
around 8000 are max for HPPA and PPC64 (ELFv1 ABI) and 7000 for SPARC64.
To keep things safe, let's use 5000 for PPC64 and 4000 for SPARC.

Co-authored-by: Michał Górny <mgorny@gentoo.org>
2024-09-23 09:03:30 +02:00
neonene 646f16bdee
gh-124153: Implement `PyType_GetBaseByToken()` and `Py_tp_token` slot (GH-124163) 2024-09-18 09:18:19 +02:00
Victor Stinner ec08aa1fe4
gh-124064: Fix -Wconversion warnings in pycore_{long,object}.h (#124177)
Change also the fix for pycore_gc.h and pycore_stackref.h:
declare constants as uintptr_t, rather than casting constants.
2024-09-17 15:35:40 +00:00
Victor Stinner 98f93a32f3
gh-124064: Fix -Wconversion warnings in pycore_{gc,list,stackref}.h (#124174) 2024-09-17 14:43:39 +00:00
Irit Katriel aba42c0b54
gh-123969: refactor _PyErr_RaiseSyntaxError and _PyErr_EmitSyntaxWarning out of compiler (#123972) 2024-09-16 15:05:00 +01:00
Irit Katriel 9aa1f60e2d
gh-124058: remove _PyCompile_IsNestedScope, roll it into _PyCompile_IsInteractive (#124061) 2024-09-16 06:58:18 -07:00
Ken Jin 8810e286fa
gh-121459: Deferred LOAD_GLOBAL (GH-123128)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Sam Gross <655866+colesbury@users.noreply.github.com>
2024-09-14 00:23:51 +08:00
Wenzel Jakob 74330d992b
gh-100554: Add ``Py_tp_vectorcall`` slot to set ``PyTypeObject.tp_vectorcall`` using the ``PyType_FromSpec`` function family. (#123332) 2024-09-13 17:40:25 +02:00
Irit Katriel fe49e8f32f
gh-124022: add missing #include (#124052) 2024-09-13 15:16:54 +00:00
Irit Katriel a9594a34c6
gh-124022: Fix bug where class docstring is removed in interactive mode (#124023)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-09-13 14:06:06 +00:00
Irit Katriel 8145ebea58
gh-124013: remove _PyCompile_IsTopLevelAwait (#124014) 2024-09-12 19:58:32 +01:00
Sam Gross b2afe2aae4
gh-123923: Defer refcounting for `f_executable` in `_PyInterpreterFrame` (#123924)
Use a `_PyStackRef` and defer the reference to `f_executable` when
possible. This avoids some reference count contention in the common case
of executing the same code object from multiple threads concurrently in
the free-threaded build.
2024-09-12 12:37:06 -04:00
Irit Katriel a2d0818c85
gh-123881: make compiler add the .generic_base base class without constructing AST nodes (#123883) 2024-09-10 16:16:00 +00:00
Irit Katriel 1a9d8917a3
gh-121404: split compile.c into compile.c and codegen.c (#123651) 2024-09-09 18:21:51 +01:00
Eric Snow d8f3c1e8f9
gh-117482: Simplify the Fix For Builtin Types Slot Wrappers (GH-122865)
In gh-121602, I applied a fix to a builtin types initialization bug.
That fix made sense in the context of some broader future changes,
but introduced a little bit of extra complexity. That fix has turned
out to be incomplete for some of the builtin types we haven't
been testing. I found that out while improving the tests.

A while back, @markshannon suggested a simpler fix that doesn't
have that problem, which I've already applied to 3.12 and 3.13.
I'm switching to that here. Given the potential long-term
benefits of the more complex (but still incomplete) approach,
I'll circle back to it in the future, particularly after I've improved
the tests so no corner cases slip through the cracks.

(This is effectively a "forward-port" of 716c677 from 3.13.)
2024-09-09 16:04:58 +02:00
Victor Stinner ef4b69d2be
gh-123747: Avoid static_assert() in internal header files (#123779) 2024-09-06 15:52:07 +02:00
Petr Viktorin ce9f84a47b
gh-97588: Move ctypes struct/union layout logic to Python (GH-123352)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-05 11:20:07 +02:00
Victor Stinner 0d6b6e34a2
gh-107954, PEP 741: Add PyInitConfig_AddModule() function (#123668) 2024-09-04 11:41:57 +00:00
Victor Stinner ef9d54703f
gh-107954, PEP 741: Add PyInitConfig C API (#123502)
Add Doc/c-api/config.rst documentation.
2024-09-03 12:33:49 +00:00
Victor Stinner 33b790978d
gh-107954, PEP 741: Add PyConfig_Get()/Set() functions (#123472)
Add PyConfig_Get(), PyConfig_GetInt(), PyConfig_Set() and
PyConfig_Names() functions to get and set the current runtime Python
configuration.

Add visibility and "sys spec" to config and preconfig specifications.

_PyConfig_AsDict() now converts PyConfig.xoptions as a dictionary.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-09-02 23:25:08 +02:00
Petr Viktorin 57c471a688
gh-123091: Use more _Py_IsImmortalLoose() (GH-123602)
Switch more _Py_IsImmortal(...) assertions to _Py_IsImmortalLoose(...)

The remaining calls to _Py_IsImmortal are in free-threaded-only code,
initialization of core objects, tests, and guards that fall back to
code that works with mortal objects.
2024-09-02 18:17:48 +02:00
Victor Stinner f1a0d96f41
gh-123091: Use _Py_IsImmortalLoose() (#123511)
Use _Py_IsImmortalLoose() in bytesobject.c, typeobject.c
and ceval.c.
2024-09-02 14:25:19 +02:00
Victor Stinner d8e69b2c1b
gh-122854: Add Py_HashBuffer() function (#122855) 2024-08-30 15:42:27 +00:00
Victor Stinner 3d60dfbe17
gh-121645: Add PyBytes_Join() function (#121646)
* Replace _PyBytes_Join() with PyBytes_Join().
* Keep _PyBytes_Join() as an alias to PyBytes_Join().
2024-08-30 12:57:33 +00:00
Matt Wozniski 7fca268bee
gh-123484: Fix the debug offsets for PyLongObject (#123485) 2024-08-30 12:39:28 +01:00
Serhiy Storchaka 32c7dbb2bc
gh-121485: Always use 64-bit integers for integers bits count (GH-121486)
Use 64-bit integers instead of platform specific size_t or Py_ssize_t
to represent the number of bits in Python integer.
2024-08-30 08:13:24 +03:00
Victor Stinner 4c6dca8292
gh-120389: Add PyLong_FromInt64() and PyLong_AsInt64() (#120390)
Add new functions to convert C <stdint.h> numbers from/to Python int:

* PyLong_FromInt32()
* PyLong_FromUInt32()
* PyLong_FromInt64()
* PyLong_FromUInt64()
* PyLong_AsInt32()
* PyLong_AsUInt32()
* PyLong_AsInt64()
* PyLong_AsUInt64()
2024-08-28 10:16:13 +00:00
Pieter Eendebak 7e38e6745d
gh-123271: Make builtin zip method safe under free-threading (#123272)
The `zip_next` function uses a common optimization technique for methods
that generate tuples. The iterator maintains an internal reference to
the returned tuple. When the method is called again, it checks if the
internal tuple's reference count is 1. If so, the tuple can be reused.
However, this approach is not safe under the free-threading build:
after checking the reference count, another thread may perform the same
check and also reuse the tuple. This can result in a double decref on
the items of the replaced tuple and a double incref (memory leak) on
the items of the tuple being set.

This adds a function, `_PyObject_IsUniquelyReferenced` that
encapsulates the stricter logic necessary for the free-threaded build:
the internal tuple must be owned by the current thread, have a local
refcount of one, and a shared refcount of zero.
2024-08-27 15:22:43 -04:00
Mark Shannon 54a05a4600
GH-123232: Factor BINARY_SLICE and STORE_SLICE to handle stats properly for tier 2. (GH-123381) 2024-08-27 10:49:39 +01:00
Mark Shannon 89328f7b12
GH-115775: Use `__static_attributes__` to initialize shared keys (GH-118468) 2024-08-27 10:34:46 +01:00
Sam Gross 556e855684
gh-117376: Make `Py_DECREF` a macro in ceval.c in free-threaded build (#122975)
`Py_DECREF` and `PyStackRef_CLOSE` are now implemented as macros in the
free-threaded build in ceval.c. There are two motivations;

 * MSVC has problems inlining functions in ceval.c in the PGO build.

 * We will want to mark escaping calls in order to spill the stack
   pointer in ceval.c and we will want to do this around `_Py_Dealloc`
   (or `_Py_MergeZeroLocalRefcount` or `_Py_DecRefShared`), not around
   the entire `Py_DECREF` or `PyStackRef_CLOSE` call.
2024-08-23 15:36:14 -04:00
Mark Shannon 5d3201fe3f
GH-123040: Specialize shadowed `LOAD_ATTR`. (GH-123219) 2024-08-23 10:22:35 +01:00
Mark Shannon a3d8c0542e
GH-123197: Only count an instruction as deferred if it hasn't deopted first. (GH-123222)
Only count an instruction as deferred if hasn't deopted first.
2024-08-22 14:17:10 +01:00
Mark Shannon a4fd7aa4a6
GH-115776: Allow any fixed sized object to have inline values (GH-123192) 2024-08-21 15:52:04 +01:00
Mark Shannon 1eba8bae92
GH-123185: Check for `NULL` after calling `_PyEvalFramePushAndInit` (GH-123194) 2024-08-21 12:44:56 +01:00
Mark Shannon bb1d30336e
GH-118093: Make `CALL_ALLOC_AND_ENTER_INIT` suitable for tier 2. (GH-123140)
* Convert CALL_ALLOC_AND_ENTER_INIT to micro-ops such that tier 2 supports it

* Allow inexact arguments for CALL_ALLOC_AND_ENTER_INIT.
2024-08-20 16:52:58 +01:00
Sam Gross 40632b1f1d
gh-122974: Suppress GCC array bound warnings in free-threaded build (#123071)
GCC 11 and newer warn about the access to `unique_id` in non-debug builds
due to inlining the call on static non-heap types.
2024-08-17 16:03:50 -04:00
Mark Shannon c13e7d98fb
GH-118093: Specialize `CALL_KW` (GH-123006) 2024-08-16 17:11:24 +01:00