summaryrefslogtreecommitdiffstats
path: root/Modules/_functoolsmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-126133: Only use start year in PSF copyright, remove end years (#126236)Hugo van Kemenade2024-11-121-1/+1
|
* gh-125916: Allow functools.reduce() 'initial' to be a keyword argument (#125917)Sayandip Dutta2024-11-121-2/+2
|
* gh-125916: Adapt functools.reduce() to Argument Clinic (#125999)Sergey B Kirpichev2024-11-011-19/+23
|
* Align functools.reduce() docstring with PEP-257 (#126045)Sergey B Kirpichev2024-10-291-6/+8
| | | Yak-shave in preparation for Argument Clinic adaption in gh-125999.
* gh-111178: fix USAN failures for `partialobject` (#124733)Bénédikt Tran2024-10-141-25/+34
|
* gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) (#125194)Victor Stinner2024-10-091-1/+1
| | | | | Replace PyUnicode_New(0, 0), PyUnicode_FromString("") and PyUnicode_FromStringAndSize("", 0) with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
* gh-119127: Fix _functools.Placeholder singleton (#124601)Victor Stinner2024-09-261-13/+35
| | | | | | | * The module state now stores a strong reference to the Placeholder singleton. * Use a regular dealloc function. * Add Py_TPFLAGS_HAVE_GC flag and a traverse function to help the GC to collect the type when a _functools extension is unloaded.
* gh-119127: functools.partial placeholders (gh-119827)dgpb2024-09-261-53/+281
|
* gh-121027: Make the functools.partial object a method descriptor (GH-121089)Serhiy Storchaka2024-07-031-8/+1
| | | Co-authored-by: d.grigonis <dgrigonis@users.noreply.github.com>
* gh-121027: Add a future warning in functools.partial.__get__ (#121086)Serhiy Storchaka2024-06-271-0/+16
|
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-031-0/+1
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-118402: Fix inspect.signature() for functools.cmp_to_key() result (GH-118427)Serhiy Storchaka2024-04-301-0/+12
|
* GH-100242: bring functools.py partial implementation more in line with C ↵CF Bolz-Tereick2024-04-171-4/+11
| | | | | | | code (GH-100244) in partial.__new__, before checking for the existence of the attribute 'func', first check whether the argument is an instance of partial.
* gh-117764: Add signature for functools.partial() (GH-117775)Serhiy Storchaka2024-04-121-2/+3
|
* gh-111696, PEP 737: Add PyType_GetModuleName() function (#116824)Victor Stinner2024-03-141-1/+1
| | | Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-72249: Include the module name in the repr of partial object (GH-101910)Furkan Onder2024-02-251-2/+19
| | | Co-authored-by: Anilyka Barry <vgr255@live.ca>
* gh-111903: Update AC to support "pycore_critical_section.h" header (gh-112251)Donghee Na2023-11-191-1/+0
|
* gh-112070: make `functools.lru_cache` threadsafe in --disable-gil build ↵Wanderxjtu2023-11-171-3/+10
| | | | | | | | | | | | | | | | | (gh-112111) * gh-112070: make `functools.lrucacle` threadsafe in --disable-gil build * gh-112070: update generate `functoolsmodule` files * gh-112070: add NEWS file * Delete Misc/NEWS.d/next/Library/2023-11-15-20-19-45.gh-issue-112070.q6OhcU.rst * gh-112070: reformat functoolsmodule.c --------- Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-111262: Add PyDict_Pop() function (#112028)Victor Stinner2023-11-141-13/+15
| | | | | | | _PyDict_Pop_KnownHash(): remove the default value and the return type becomes an int. Co-authored-by: Stefan Behnel <stefan_ml@behnel.de> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
* gh-102757: fix function signature mismatch for `functools.reduce` between ↵Xuehai Pan2023-09-181-1/+1
| | | | code and documentation (#102759)
* gh-106869: Use new PyMemberDef constant names (#106871)Victor Stinner2023-07-251-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove '#include "structmember.h"'. * If needed, add <stddef.h> to get offsetof() function. * Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Replace: * T_SHORT => Py_T_SHORT * T_INT => Py_T_INT * T_LONG => Py_T_LONG * T_FLOAT => Py_T_FLOAT * T_DOUBLE => Py_T_DOUBLE * T_STRING => Py_T_STRING * T_OBJECT => _Py_T_OBJECT * T_CHAR => Py_T_CHAR * T_BYTE => Py_T_BYTE * T_UBYTE => Py_T_UBYTE * T_USHORT => Py_T_USHORT * T_UINT => Py_T_UINT * T_ULONG => Py_T_ULONG * T_STRING_INPLACE => Py_T_STRING_INPLACE * T_BOOL => Py_T_BOOL * T_OBJECT_EX => Py_T_OBJECT_EX * T_LONGLONG => Py_T_LONGLONG * T_ULONGLONG => Py_T_ULONGLONG * T_PYSSIZET => Py_T_PYSSIZET * T_NONE => _Py_T_NONE * READONLY => Py_READONLY * PY_AUDIT_READ => Py_AUDIT_READ * READ_RESTRICTED => Py_AUDIT_READ * PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED * RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
* gh-106023: Update code using _PyObject_FastCall() (#106257)Victor Stinner2023-06-301-14/+7
| | | Replace _PyObject_FastCall() calls with PyObject_Vectorcall().
* gh-106084: Remove old PyObject call aliases (#106085)Victor Stinner2023-06-261-1/+1
| | | | | | | | | | | | | | Remove old aliases which were kept backwards compatibility with Python 3.8: * _PyObject_CallMethodNoArgs() * _PyObject_CallMethodOneArg() * _PyObject_CallOneArg() * _PyObject_FastCallDict() * _PyObject_Vectorcall() * _PyObject_VectorcallMethod() * _PyVectorcall_Function() Update code which used these aliases to use new names.
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-0/+1
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* gh-99537: Use Py_SETREF() function in C code (#99656)Victor Stinner2022-11-221-2/+1
| | | | | | | | | | | | | | | Fix potential race condition in code patterns: * Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);" * Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);" * Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);" Other changes: * Replace "old = var; var = new; Py_DECREF(var)" with "Py_SETREF(var, new);" * Replace "old = var; var = new; Py_XDECREF(var)" with "Py_XSETREF(var, new);" * And remove the "old" variable.
* gh-81057: Move the global Dict-Related Versions to _PyRuntimeState (gh-99497)Eric Snow2022-11-161-0/+1
| | | | | We also move the global func version. https://github.com/python/cpython/issues/81057
* gh-99300: Use Py_NewRef() in Modules/ directory (#99466)Victor Stinner2022-11-141-46/+23
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
* gh-64373: Convert `_functools` to Argument Clinic (#96640)Nikita Sobolev2022-10-071-29/+57
|
* gh-96641: Do not expose `KeyWrapper` in `_functoolsmodule.c` (gh-96642)Nikita Sobolev2022-09-071-3/+2
|
* gh-91320: Use _PyCFunction_CAST() (#92251)Victor Stinner2022-05-031-1/+1
| | | | | | | | | | Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). Change generated by the command: sed -i -e \ 's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \ $(find -name "*.c")
* bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081)Petr Viktorin2022-02-111-1/+1
| | | | | * Make PyType_GetModuleByDef public (remove underscore) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-45439: Move _PyObject_VectorcallTstate() to pycore_call.h (GH-28893)Victor Stinner2021-10-141-1/+1
| | | | | | | | | | | * Move _PyObject_VectorcallTstate() and _PyObject_FastCallTstate() to pycore_call.h (internal C API). * Convert PyObject_CallOneArg(), PyObject_Vectorcall(), _PyObject_FastCall() and PyVectorcall_Function() static inline functions to regular functions. * Add _PyVectorcall_FunctionInline() static inline function. * PyObject_Vectorcall(), _PyObject_FastCall(), and PyObject_CallOneArg() now call _PyThreadState_GET() rather than PyThreadState_Get().
* bpo-45439: Move _PyObject_CallNoArgs() to pycore_call.h (GH-28895)Victor Stinner2021-10-121-0/+1
| | | | | | | * Move _PyObject_CallNoArgs() to pycore_call.h (internal C API). * _ssl, _sqlite and _testcapi extensions now call the public PyObject_CallNoArgs() function, rather than _PyObject_CallNoArgs(). * _lsprof extension is now built with Py_BUILD_CORE_MODULE macro defined to get access to internal _PyObject_CallNoArgs().
* bpo-45439: Rename _PyObject_CallNoArg() to _PyObject_CallNoArgs() (GH-28891)Victor Stinner2021-10-111-1/+1
| | | | | Fix typo in the private _PyObject_CallNoArg() function name: rename it to _PyObject_CallNoArgs() to be consistent with the public function PyObject_CallNoArgs().
* Clean up initialization __class_getitem__ with Py_GenericAlias. (GH-28450)Serhiy Storchaka2021-09-191-1/+1
| | | | | The cast to PyCFunction is redundant. Overuse of redundant casts can hide actual bugs.
* bpo-45094: Add Py_NO_INLINE macro (GH-28140)Victor Stinner2021-09-031-1/+1
| | | | | * Rename _Py_NO_INLINE macro to Py_NO_INLINE: make it public and document it. * Sort macros in the C API documentation.
* bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351)Erlend Egeberg Aasland2021-06-171-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Make functools types immutable * Multibyte codec types are now immutable * pyexpat.xmlparser is now immutable * array.arrayiterator is now immutable * _thread types are now immutable * _csv types are now immutable * _queue.SimpleQueue is now immutable * mmap.mmap is now immutable * unicodedata.UCD is now immutable * sqlite3 types are now immutable * _lsprof.Profiler is now immutable * _overlapped.Overlapped is now immutable * _operator types are now immutable * winapi__overlapped.Overlapped is now immutable * _lzma types are now immutable * _bz2 types are now immutable * _dbm.dbm and _gdbm.gdbm are now immutable
* bpo-42972: Fully implement GC protocol for functools LRU cache (GH-26423)Erlend Egeberg Aasland2021-05-281-2/+4
|
* bpo-42972: Fully implement GC protocol for functools keywrapper and partial ↵Erlend Egeberg Aasland2021-05-281-22/+37
| | | | types (GH-26363)
* bpo-44256: Do not expose _functools._list_elem_type (GH-26416)Inada Naoki2021-05-281-3/+2
| | | It is internal use only type.
* bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)Erlend Egeberg Aasland2021-04-301-2/+2
| | | | | | | | | | | | | | | | | | | | | Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to the following types: * _dbm.dbm * _gdbm.gdbm * _multibytecodec.MultibyteCodec * _sre..SRE_Scanner * _thread._localdummy * _thread.lock * _winapi.Overlapped * array.arrayiterator * functools.KeyWrapper * functools._lru_list_elem * pyexpat.xmlparser * re.Match * re.Pattern * unicodedata.UCD * zlib.Compress * zlib.Decompress
* bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)Victor Stinner2021-04-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add pycore_moduleobject.h internal header file with static inline functions to access module members: * _PyModule_GetDict() * _PyModule_GetDef() * _PyModule_GetState() These functions don't check at runtime if their argument has a valid type and can be inlined even if Python is not built with LTO. _PyType_GetModuleByDef() uses _PyModule_GetDef(). Replace PyModule_GetState() with _PyModule_GetState() in the extension modules, considered as performance sensitive: * _abc * _functools * _operator * _pickle * _queue * _random * _sre * _struct * _thread * _winapi * array * posix The following extensions are now built with the Py_BUILD_CORE_MODULE macro defined, to be able to use the internal pycore_moduleobject.h header: _abc, array, _operator, _queue, _sre, _struct.
* bpo-40137: Move state lookups out of the critical path (GH-25492)Raymond Hettinger2021-04-211-28/+36
|
* bpo-40137: Fix refleak in _functools_exec() (GH-24006)Victor Stinner2020-12-301-0/+1
|
* bpo-40137: Convert _functools module to use PyType_FromModuleAndSpec. (GH-23405)Hai Shi2020-12-291-222/+253
|
* bpo-42536: GC track recycled tuples (GH-23623)Brandt Bucher2020-12-051-0/+6
| | | | | | | | | | | | | | | | Several built-in and standard library types now ensure that their internal result tuples are always tracked by the garbage collector: - collections.OrderedDict.items - dict.items - enumerate - functools.reduce - itertools.combinations - itertools.combinations_with_replacement - itertools.permutations - itertools.product - itertools.zip_longest - zip Previously, they could have become untracked by a prior garbage collection.
* bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)Victor Stinner2020-12-011-2/+2
| | | | | | | | | No longer use deprecated aliases to functions: * Replace PyObject_MALLOC() with PyObject_Malloc() * Replace PyObject_REALLOC() with PyObject_Realloc() * Replace PyObject_FREE() with PyObject_Free() * Replace PyObject_Del() with PyObject_Free() * Replace PyObject_DEL() with PyObject_Free()
* bpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)Victor Stinner2020-10-271-1/+2
| | | | | | Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory. _cursesmodule.c and zoneinfo.c are now built with Py_BUILD_CORE_MODULE macro defined.
* bpo-31082: Use "iterable" in the docstring for functools.reduce() (GH-20796)Zackery Spytz2020-06-281-7/+7
|
* bpo-41078: Rename pycore_tupleobject.h to pycore_tuple.h (GH-21056)Victor Stinner2020-06-221-1/+1
|