summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* gh-119396: Optimize unicode_decode_utf8_writer() (#119957)Victor Stinner2024-06-031-5/+4
| | | | | | Optimize unicode_decode_utf8_writer() Take the ascii_decode() fast-path even if dest is not aligned on size_t bytes.
* gh-117657: Fix data races report by TSAN unicode-hash (gh-119907)Donghee Na2024-06-031-8/+11
|
* gh-119740: Remove deprecated trunc delegation (#119743)Mark Dickinson2024-06-021-32/+0
| | | | | | | | Remove the delegation of `int` to the `__trunc__` special method: `int` will now only delegate to `__int__` and `__index__` (in that order). `__trunc__` continues to exist, but its sole purpose is to support `math.trunc`. --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-119775: Remove ability to create immutable types with mutable bases (#119776)Nikita Sobolev2024-06-021-10/+6
|
* gh-74929: PEP 667 C API documentation (gh-119379)Alyssa Coghlan2024-06-011-2/+7
| | | | | | | | * Add docs for new APIs * Add soft-deprecation notices * Add What's New porting entries * Update comments referencing `PyFrame_LocalsToFast()` to mention the proxy instead * Other related cleanups found when looking for refs to the deprecated APIs
* gh-119180: Lazily wrap annotations on classmethod and staticmethod (#119864)Jelle Zijlstra2024-05-311-1/+99
|
* gh-109218: Deprecate weird cases in the complex() constructor (GH-119620)Serhiy Storchaka2024-05-301-39/+100
| | | | | | | * Passing a string as the "real" keyword argument is now an error; it should only be passed as a single positional argument. * Passing a complex number as the "real" or "imag" argument is now deprecated; it should only be passed as a single positional argument.
* gh-109218: Improve documentation for the complex() constructor (GH-119687)Serhiy Storchaka2024-05-302-6/+12
| | | | | | | | | | | | | | * Remove the equivalence with real+imag*1j which can be incorrect in corner cases (non-finite numbers, the sign of zeroes). * Separately document the three roles of the constructor: parsing a string, converting a number, and constructing a complex from components. * Document positional-only parameters of complex(), float(), int() and bool() as positional-only. * Add examples for complex() and int(). * Specify the grammar of the string for complex(). * Improve the grammar of the string for float(). * Describe more explicitly the behavior when real and/or imag arguments are complex numbers. (This will be deprecated in future.)
* gh-119525: Fix deadlock with `_PyType_Lookup` and the GIL (#119527)Sam Gross2024-05-291-4/+7
| | | | | | | | | | The deadlock only affected the free-threaded build and only occurred when the GIL was enabled at runtime. The `Py_DECREF(old_name)` call might temporarily release the GIL while holding the type seqlock. Another thread may spin trying to acquire the seqlock while holding the GIL. The deadlock occurred roughly 1 in ~1,000 runs of `pool_in_threads.py` from `test_multiprocessing_pool_circular_import`.
* gh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#119619)Sergey B Kirpichev2024-05-293-21/+21
|
* gh-119011: `type.__type_params__` now return an empty tuple (#119296)Nikita Sobolev2024-05-281-0/+4
|
* gh-119396: Optimize unicode_repr() (#119617)Victor Stinner2024-05-282-102/+129
| | | | | | | | | | | | | | | | | | | | | | 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 | +-------------------------------------+---------+----------------------+
* gh-117557: Improve error messages when a string, bytes or bytearray of ↵Serhiy Storchaka2024-05-283-23/+78
| | | | length 1 are expected (GH-117631)
* gh-111999: Fix the signature of str.format_map() (#119540)Serhiy Storchaka2024-05-251-1/+1
|
* gh-112075: Fix dict thread safety issues (#119288)Germán Méndez Bravo2024-05-241-25/+41
| | | Fix dict thread safety issues
* GH-117195: Avoid assertion error in `object.__sizeof__` (GH-117220)Mark Shannon2024-05-231-2/+5
|
* Tiny fix: Update link for HAC algorithm (gh-118546)Ayato Hayashi2024-05-231-2/+2
|
* gh-119396: Optimize PyUnicode_FromFormat() UTF-8 decoder (#119398)Victor Stinner2024-05-221-62/+141
| | | | | | | | | | | | | | | | | Add unicode_decode_utf8_writer() to write directly characters into a _PyUnicodeWriter writer: avoid the creation of a temporary string. Optimize PyUnicode_FromFormat() by using the new unicode_decode_utf8_writer(). Rename unicode_fromformat_write_cstr() to unicode_fromformat_write_utf8(). Microbenchmark on the code: return PyUnicode_FromFormat( "%s %s %s %s %s.", "format", "multiple", "utf8", "short", "strings"); Result: 620 ns +- 8 ns -> 382 ns +- 2 ns: 1.62x faster.
* gh-119247: Add macros to use PySequence_Fast safely in free-threaded build ↵Josh {*()} Rosenberg2024-05-221-3/+5
| | | | | | | | (#119315) Add `Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST` and `Py_END_CRITICAL_SECTION_SEQUENCE_FAST` macros and update `str.join` to use them. Also add a regression test that would crash reliably without this patch.
* gh-117657: Fix missing atomic in dict_resize (#119312)Dino Viehland2024-05-221-1/+1
| | | Fix missing atomic in dict_resize
* Remove almost all unpaired backticks in docstrings (#119231)Geoffrey Thomas2024-05-222-12/+12
| | | | | | | | | | | | | | | | | | As reported in #117847 and #115366, an unpaired backtick in a docstring tends to confuse e.g. Sphinx running on subclasses of standard library objects, and the typographic style of using a backtick as an opening quote is no longer in favor. Convert almost all uses of the form The variable `foo' should do xyz to The variable 'foo' should do xyz and also fix up miscellaneous other unpaired backticks (extraneous / missing characters). No functional change is intended here other than in human-readable docstrings.
* gh-119180: PEP 649: Add __annotate__ attributes (#119209)Jelle Zijlstra2024-05-223-16/+268
|
* gh-119180: Add LOAD_COMMON_CONSTANT opcode (#119321)Jelle Zijlstra2024-05-221-1/+1
| | | | | | | | | | The PEP 649 implementation will require a way to load NotImplementedError from the bytecode. @markshannon suggested implementing this by converting LOAD_ASSERTION_ERROR into a more general mechanism for loading constants. This PR adds this new opcode. I will work on the rest of the implementation of the PEP separately. Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* gh-111389: Add PyHASH_MULTIPLIER constant (#119214)Victor Stinner2024-05-211-1/+1
|
* gh-109176: replace _PyFrame_OpAlreadyRan by an assertion that the frame is ↵Irit Katriel2024-05-211-33/+2
| | | | complete. (#119234)
* gh-119053: Implement the fast path for list.__getitem__ (gh-119112)Donghee Na2024-05-211-5/+10
|
* gh-118921: Add `copy()` method for `FrameLocalsProxy` (#118923)Tian Gao2024-05-101-0/+19
|
* gh-118702: Implement vectorcall for BaseException (#118703)Victor Stinner2024-05-101-0/+40
| | | | | | | | | | * BaseException_vectorcall() now creates a tuple from 'args' array. * Creation an exception using BaseException_vectorcall() is now a single function call, rather than having to call BaseException_new() and then BaseException_init(). Calling BaseException_init() is inefficient since it overrides the 'args' attribute. * _PyErr_SetKeyError() now uses PyObject_CallOneArg() to create the KeyError instance to use BaseException_vectorcall().
* Rename `notimplemented_methods` into `nodefault_methods` (#118896)Nikita Sobolev2024-05-101-4/+4
|
* Fix some missing null checks. (GH-118721)Steve Dower2024-05-101-5/+8
|
* gh-118561: Fix crash involving list.extend in free-threaded build (#118723)Sam Gross2024-05-091-1/+2
| | | | | | | The `list_preallocate_exact` function did not zero initialize array contents. In the free-threaded build, this could expose uninitialized memory to concurrent readers between the call to `list_preallocate_exact` and the filling of the array contents with items.
* gh-118849: Fix "code will never be executed" warning in `dictobject.c` (#118850)Nikita Sobolev2024-05-091-1/+1
|
* gh-117657: Fix data races when writing / reading `ob_gc_bits` (#118292)mpage2024-05-081-1/+1
| | | | | Use relaxed atomics when reading / writing to the field. There are still a few places in the GC where we do not use atomics. Those should be safe as the world is stopped.
* gh-118767: Make bool(NotImplemented) raise TypeError (#118775)Jelle Zijlstra2024-05-081-7/+3
|
* gh-118746: Fix crash in frame_getlocals and _PyFrame_GetLocals (#118748)Tian Gao2024-05-081-0/+18
| | | | We don't know how to create an unoptimized frame with f_locals == NULL, but they are seen in the wild, and this fixes the crash.
* gh-110209: Add __class_getitem__ for generator and coroutine (#110212)James Hilton-Balfe2024-05-071-0/+2
|
* gh-118527: Intern code consts in free-threaded build (#118667)Sam Gross2024-05-072-14/+294
| | | | | | We already intern and immortalize most string constants. In the free-threaded build, other constants can be a source of reference count contention because they are shared by all threads running the same code objects.
* gh-112075: Fix race in constructing dict for instance (#118499)Dino Viehland2024-05-062-70/+74
|
* gh-118527: Intern code name and filename on default build (#118576)Sam Gross2024-05-061-2/+0
| | | | Interned and non-interned strings are treated differently by `marshal`, so be consistent between the default and free-threaded build.
* GH-115709: Invalidate executors when a local variable is changed via ↵Mark Shannon2024-05-061-1/+2
| | | | | frame.f_locals (#118639) Also fix unrelated assert in debug Tier2/JIT builds.
* gh-118362: Fix thread safety around lookups from the type cache in the face ↵Dino Viehland2024-05-064-118/+263
| | | | | | | of concurrent mutators (#118454) Add _PyType_LookupRef and use incref before setting attribute on type Makes setting an attribute on a class and signaling type modified atomic Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated
* GH-117714: implement athrow().close() and asend().close() using throw ↵Thomas Grainger2024-05-061-4/+38
| | | | | | | | | | | | | | | | | | (GH-117906) * GH-117714: replace athrow().close() and asend().close() stubs with implimentations * test athrow().close() and asend().close() raises RuntimeError * 📜🤖 Added by blurb_it. * Update Objects/genobject.c Co-authored-by: Petr Viktorin <encukou@gmail.com> --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Module_SetGIL ↵Petr Viktorin2024-05-061-1/+1
| | | | (GH-118645)
* gh-118609: Add proper error check for framelocalsproxy (#118615)Tian Gao2024-05-061-46/+99
|
* gh-74929: Make containment checks more efficient in `FrameLocalsProxy` (#118624)Tian Gao2024-05-061-10/+19
| | | Properly implement the `sq_contains` slot for frame locals proxy containment checks.
* gh-118605: Fix reference leak in FrameLocalsProxy (#118607)Tian Gao2024-05-051-3/+28
| | | Also add some error checks.
* gh-74929: Remove undesirable DECREF in PEP 667 implementation (#118583)Tian Gao2024-05-051-1/+0
| | | | With tests.
* gh-74929: Implement PEP 667 (GH-115153)Tian Gao2024-05-042-199/+662
|
* gh-118527: Intern filename, name, and qualname in code objects. (#118558)Sam Gross2024-05-031-0/+5
| | | | | | This interns the strings for `co_filename`, `co_name`, and `co_qualname` on codeobjects in the free-threaded build. This partially addresses a reference counting bottleneck when creating closures concurrently. The closures take the name and qualified name from the code object.
* gh-117657: Disable the function/code cache in free-threaded builds (#118301)mpage2024-05-032-0/+16
| | | | This is only used by the specializing interpreter and the tier 2 optimizer, both of which are disabled in free-threaded builds.