summaryrefslogtreecommitdiffstats
path: root/Objects/clinic
Commit message (Collapse)AuthorAgeFilesLines
* gh-121905: Consistently use "floating-point" instead of "floating point" ↵Serhiy Storchaka2024-07-191-3/+3
| | | | (GH-121907)
* gh-84978: Add float.from_number() and complex.from_number() (GH-26827)Serhiy Storchaka2024-07-152-2/+20
| | | | | | They are alternate constructors which only accept numbers (including objects with special methods __float__, __complex__ and __index__), but not strings.
* gh-120080: Accept ``None`` as a valid argument for direct call of the ↵Kirill Podoprigora2024-06-071-3/+3
| | | | | ``int.__round__`` (#120088) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-109218: Improve documentation for the complex() constructor (GH-119687)Serhiy Storchaka2024-05-301-3/+6
| | | | | | | | | | | | | | * 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-116126: Implement PEP 696 (#116129)Jelle Zijlstra2024-05-031-33/+137
| | | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* fix formatting of literal in docstring of int.from_bytes and int.to_bytes ↵Jens Hedegaard Nielsen2024-04-181-3/+3
| | | | (#117847)
* gh-117764: Fix and add signatures for many builtins (GH-117769)Serhiy Storchaka2024-04-121-1/+7
|
* gh-117431: Adapt bytes and bytearray .find() and friends to Argument Clinic ↵Erlend E. Aasland2024-04-122-2/+508
| | | | | | | | | | | | | | (#117502) This change gives a significant speedup, as the METH_FASTCALL calling convention is now used. The following bytes and bytearray methods are adapted: - count() - find() - index() - rfind() - rindex() Co-authored-by: Inada Naoki <songofacandy@gmail.com>
* gh-117431: Argument Clinic: copy forced text signature when cloning (#117591)Erlend E. Aasland2024-04-101-5/+5
|
* gh-117431: Adapt str.find and friends to Argument Clinic (#117468)Erlend E. Aasland2024-04-031-1/+280
| | | | | | | | | | This change gives a significant speedup, as the METH_FASTCALL calling convention is now used. The following methods are adapted: - str.count - str.find - str.index - str.rfind - str.rindex
* gh-117431: Adapt bytes and bytearray .startswith() and .endswith() to ↵Erlend E. Aasland2024-04-032-2/+206
| | | | | | Argument Clinic (#117495) This change gives a significant speedup, as the METH_FASTCALL calling convention is now used.
* gh-117431: Fix str.endswith docstring (#117499)Erlend E. Aasland2024-04-031-4/+4
| | | | | The first parameter is named 'suffix', not 'prefix'. Regression introduced by commit 444156ed
* gh-117431: Adapt str.startswith and str.endswith to Argument Clinic (#117466)Erlend E. Aasland2024-04-031-1/+103
| | | | This change gives a significant speedup, as the METH_FASTCALL calling convention is now used.
* gh-116621: Set manual critical section for list.extend (gh-116657)Donghee Na2024-03-121-19/+4
|
* gh-112087: Make list.sort to be thread-safe for PEP 703. (gh-116553)Donghee Na2024-03-101-1/+3
|
* gh-112069: Make sets thread-safe with the GIL disabled (#113800)Tomas R2024-03-081-7/+164
| | | | | | This makes nearly all the operations on set thread-safe in the free-threaded build, with the exception of `_PySet_NextEntry` and `setiter_iternext`. Co-authored-by: Sam Gross <colesbury@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-112075: Accessing a single element should optimistically avoid locking ↵Dino Viehland2024-02-211-16/+1
| | | | | (#115109) Makes accessing a single element thread safe and typically lock free
* gh-112069: Adapt set/frozenset methods to Argument Clinic (#115112)Tomas R2024-02-081-0/+414
|
* gh-112075: Add critical sections for most dict APIs (#114508)Dino Viehland2024-02-061-2/+28
| | | | | | | | | Starts adding thread safety to dict objects. Use @critical_section for APIs which are exposed via argument clinic and don't directly correlate with a public C API which needs to acquire the lock Use a _lock_held suffix for keeping changes to complicated functions simple and just wrapping them with a critical section Acquire and release the lock in an existing function where it won't be overly disruptive to the existing logic
* gh-112075: Adapt more dict methods to Argument Clinic (#114256)Dino Viehland2024-01-231-1/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Move more dict objects to argument clinic * Improve doc strings * More doc string improvements * Update Objects/dictobject.c Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> * Update Objects/dictobject.c Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> * Update Objects/dictobject.c Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> * Update Objects/dictobject.c Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> * Update Objects/dictobject.c Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> * Update Objects/dictobject.c Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> * Update Objects/dictobject.c Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> --------- Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* gh-112087: Update list impl to be thread-safe with manual CS (gh-113863)Donghee Na2024-01-161-2/+38
|
* gh-112640: Add `kwdefaults` parameter to `types.FunctionType.__new__` (#112641)Nikita Sobolev2024-01-111-11/+22
|
* gh-112087: Update list.{pop,clear,reverse,remove} to use CS (gh-113764)Donghee Na2024-01-091-3/+35
|
* gh-110383: Improve accuracy of str.split() and str.rsplit() docstrings (#113355)Erlend E. Aasland2023-12-211-3/+5
| | | | Clarify split direction in the docstring body, instead of in the 'maxsplit' param docstring.
* gh-111138: Add PyList_Extend() and PyList_Clear() functions (#111862)Victor Stinner2023-11-131-10/+10
| | | | | | * Split list_extend() into two sub-functions: list_extend_fast() and list_extend_iter(). * list_inplace_concat() no longer has to call Py_DECREF() on the list_extend() result, since list_extend() now returns an int.
* gh-111089: Revert PyUnicode_AsUTF8() changes (#111833)Victor Stinner2023-11-075-19/+89
| | | | | | | | | | | | | | | | | | | | | * Revert "gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)" This reverts commit d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2. * Revert "gh-111089: Use PyUnicode_AsUTF8() in getargs.c (#111620)" This reverts commit cde1071b2a72e8261ca66053ef61431b7f3a81fd. * Revert "gh-111089: PyUnicode_AsUTF8() now raises on embedded NUL (#111091)" This reverts commit d731579bfb9a497cfb0076cb6b221058a20088fe. * Revert "gh-111089: Add PyUnicode_AsUTF8() to the limited C API (#111121)" This reverts commit d8f32be5b6a736dc2fc9dca3f1bf176c82fc9b44. * Revert "gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)" This reverts commit 37e4e20eaa8f27ada926d49e5971fecf0477ad26.
* gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)Victor Stinner2023-11-015-89/+19
| | | | | | | Replace PyUnicode_AsUTF8AndSize() with PyUnicode_AsUTF8() to remove the explicit check for embedded null characters. The change avoids to have to include explicitly <string.h> to get the strlen() function when using a recent version of the limited C API.
* gh-67565: Remove redundant C-contiguity checks (GH-105521)Furkan Onder2023-10-232-58/+2
| | | | Co-authored-by: Stefan Krah <skrah@bytereef.org>
* gh-110964: Remove private _PyArg functions (#110966)Victor Stinner2023-10-1720-20/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the following private functions and structures to pycore_modsupport.h internal C API: * _PyArg_BadArgument() * _PyArg_CheckPositional() * _PyArg_NoKeywords() * _PyArg_NoPositional() * _PyArg_ParseStack() * _PyArg_ParseStackAndKeywords() * _PyArg_Parser structure * _PyArg_UnpackKeywords() * _PyArg_UnpackKeywordsWithVararg() * _PyArg_UnpackStack() * _Py_ANY_VARARGS() Changes: * Python/getargs.h now includes pycore_modsupport.h to export functions. * clinic.py now adds pycore_modsupport.h when one of these functions is used. * Add pycore_modsupport.h includes when a C extension uses one of these functions. * Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog * _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple(). * _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c. * Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file. * Fix mypy clinic.py
* gh-110907: AC: Disallow using `*` with vararg (#110908)Nikita Sobolev2023-10-161-2/+2
|
* gh-108915: Removes extra backslashes in str.split docstring (#109044)Daniel Weiss2023-09-071-3/+3
|
* gh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)Victor Stinner2023-08-3120-100/+55
| | | | | | | | | | | | | | | | | | | | Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed, and only includes pycore_runtime.h if _Py_ID() is needed. * Add 'condition' optional argument to Clinic.add_include(). * deprecate_keyword_use() includes pycore_runtime.h when using the _PyID() function. * Fix rendering of includes: comments start at the column 35. * Mark PC/clinic/_wmimodule.cpp.h and "Objects/stringlib/clinic/*.h.h" header files as generated in .gitattributes. Effects: * 42 header files generated by AC no longer include the internal C API, instead of 4 header files before. For example, Modules/clinic/_abc.c.h no longer includes the internal C API. * Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h to get _Py_ID().
* gh-108635: Make parameters of some implementations of special methods ↵Serhiy Storchaka2023-08-291-207/+15
| | | | positional-only (GH-108636)
* gh-106320: Remove private AC converter functions (#108505)Victor Stinner2023-08-265-5/+10
| | | | | | | | | | | | | | Move these private functions to the internal C API (pycore_abstract.h): * _Py_convert_optional_to_ssize_t() * _PyNumber_Index() Argument Clinic now emits #include "pycore_abstract.h" when these functions are used. The parser of the c-analyzer tool now uses a list of files which use the limited C API, rather than a list of files using the internal C API.
* gh-108444: Argument Clinic uses PyLong_AsInt() (#108458)Victor Stinner2023-08-246-28/+28
| | | | Argument Clinic now uses the new public PyLong_AsInt(), rather than the old name _PyLong_AsInt().
* gh-86457: Fix signature for code.replace() (GH-23199)Serhiy Storchaka2023-08-071-20/+14
| | | | Also add support of @text_signature in Argument Clinic.
* gh-106487: Allow the 'count' argument of `str.replace` to be a keyword (#106488)Hugo van Kemenade2023-07-101-8/+36
|
* fix typos (#106247)Inada Naoki2023-06-302-4/+4
| | | Most typos are in comments, but two typos are in docstring.
* gh-92536: Argument Clinic no longer emits PyUnicode_READY() (#105208)Victor Stinner2023-06-0110-79/+10
| | | | | | Since Python 3.12, PyUnicode_READY() does nothing and always returns 0. Argument Clinic now also checks for .cpp files (PC/_wmimodule.cpp).
* gh-103763: Implement PEP 695 (#103764)Jelle Zijlstra2023-05-161-0/+786
| | | | | | | | | | | | | | This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-102500: Implement PEP 688 (#102521)Jelle Zijlstra2023-05-041-1/+61
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-101825: Clarify that as_integer_ratio() output is always normalized (#101843)Sergey B Kirpichev2023-02-272-10/+7
| | | | | | | | | Make docstrings for `as_integer_ratio` consistent across types, and document that the returned pair is always normalized (coprime integers, with positive denominator). --------- Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-101409: Improve generated clinic code for self type checks (#101411)Erlend E. Aasland2023-01-316-20/+21
|
* gh-100268: Add is_integer method to int (#100439)Shantanu2022-12-241-1/+19
| | | This improves the lives of type annotation users of `float` - which type checkers implicitly treat as `int|float` because that is what most code actually wants. Before this change a `.is_integer()` method could not be assumed to exist on things annotated as `: float` due to the method not existing on both types.
* bpo-15999: Accept arbitrary values for boolean parameters. (#15609)Serhiy Storchaka2022-12-034-12/+12
| | | builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
* gh-96526: Clarify format and __format__ docstrings (gh-96648)Michael2022-10-032-4/+7
|
* gh-90928: Improve static initialization of keywords tuple in AC (#95907)Erlend E. Aasland2022-08-1314-728/+308
|
* gh-90928: Statically Initialize the Keywords Tuple in Clinic-Generated Code ↵Eric Snow2022-08-1119-61/+1561
| | | | | | | | | | | | | | | | (gh-95860) We only statically initialize for core code and builtin modules. Extension modules still create the tuple at runtime. We'll solve that part of interpreter isolation separately. This change includes generated code. The non-generated changes are in: * Tools/clinic/clinic.py * Python/getargs.c * Include/cpython/modsupport.h * Makefile.pre.in (re-generate global strings after running clinic) * very minor tweaks to Modules/_codecsmodule.c and Python/Python-tokenize.c All other changes are generated code (clinic, global strings).
* gh-91320: Argument Clinic uses _PyCFunction_CAST() (#32210)Victor Stinner2022-05-0311-72/+72
| | | | Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func).
* GH-88116: Use a compact format to represent end line and column offsets. ↵Mark Shannon2022-04-211-45/+25
| | | | | | | | | | | | (GH-91666) * Stores all location info in linetable to conform to PEP 626. * Remove column table from code objects. * Remove end-line table from code objects. * Document new location table format