dgpb
afed5f8835
gh-125028: Prohibit placeholders in partial keywords (GH-126062)
2025-05-08 10:53:53 +03:00
Lukas Geiger
0147be09d5
gh-131525: Remove `_HashedSeq` wrapper from `lru_cache` (gh-131922)
2025-03-31 08:23:41 -05:00
Serhiy Storchaka
f33d21e24f
gh-127750: Improve repr of functools.singledispatchmethod (GH-130220)
2025-03-05 13:10:05 +02:00
Jelle Zijlstra
dc6d66f44c
gh-105499: Merge typing.Union and types.UnionType ( #105511 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2025-03-04 11:44:19 -08:00
Serhiy Storchaka
10b32054ad
gh-127750: Restore inspect and pydoc support of singledispatchmethod (GH-130309)
...
The code is still flawed, because it does not recognize class and static
methods, and the first argument is not removed from the signature of
bound methods, but at least it does not worse than in 3.13 and older.
2025-02-20 11:08:49 +02:00
Serhiy Storchaka
395335d0ff
gh-127750: Fix and optimize functools.singledispatchmethod() (GH-130008)
...
Remove broken singledispatchmethod caching introduced in gh-85160.
Achieve the same performance using different optimization.
* Add more tests.
* Fix issues with __module__ and __doc__ descriptors.
2025-02-17 11:11:20 +02:00
Kirill Podoprigora
d903b17499
gh-121676: Raise a ``DeprecationWarning`` if the Python implementation of ``functools.reduce`` is called with `function` or `sequence` as a keyword args ( #121677 )
...
Python implementation of `functools` allows calling `reduce`
with `function` or `sequence` as keyword args. This doesn't
match behavior of our C accelerator and our documentation
for `functools.reduce` states that `function`and `sequence`
are positional-only arguments.
Now calling a Python implementation of `functools.reduce`
with `function` or `sequence` as keyword args would raise
a `DeprecationWarning` and is planned to be prohibited in
Python 3.16.
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-01 13:36:47 +02:00
CF Bolz-Tereick
401bba6b58
gh-127537: Add __class_getitem__ to the python implementation of functools.partial ( #127537 )
2024-12-26 17:03:47 -08:00
Hugo van Kemenade
91f4908798
gh-126133: Only use start year in PSF copyright, remove end years ( #126236 )
2024-11-12 15:59:19 +02:00
Sayandip Dutta
abb90ba46c
gh-125916: Allow functools.reduce() 'initial' to be a keyword argument ( #125917 )
2024-11-12 13:11:58 +00:00
Sergey B Kirpichev
9b14083497
Align functools.reduce() docstring with PEP-257 ( #126045 )
...
Yak-shave in preparation for Argument Clinic adaption in gh-125999.
2024-10-29 08:08:08 +00:00
Jelle Zijlstra
95581b3551
functools: Give up on lazy-importing types ( #124736 )
...
PR #121089 added an eager import for types.MethodType, but
still left the existing hacks for lazily importing from types.
We could also create MethodType internally in functools.py (e.g.,
by using `type(Placeholder.__repr__)`, but it feels not worth it at
this point, so instead I unlazified all the usages of types in the
module.
2024-09-29 06:31:06 -07:00
dgpb
d9296529eb
gh-119127: functools.partial placeholders (gh-119827)
2024-09-26 01:04:38 +00:00
Jelle Zijlstra
7b7b90d1ce
gh-119180: Add `annotationlib` module to support PEP 649 ( #119891 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-07-23 21:16:50 +00:00
Serhiy Storchaka
ff5806c78e
gh-121027: Make the functools.partial object a method descriptor (GH-121089)
...
Co-authored-by: d.grigonis <dgrigonis@users.noreply.github.com>
2024-07-03 09:02:15 +03:00
Serhiy Storchaka
db96edd6d1
gh-121027: Add a future warning in functools.partial.__get__ ( #121086 )
2024-06-27 11:47:20 +00:00
Bénédikt Tran
d2646e3f45
gh-121025: Improve partialmethod.__repr__ (GH-121033)
...
It no longer contains redundant commas and spaces.
2024-06-26 12:08:27 +03:00
CF Bolz-Tereick
5a0209fc23
GH-100242: bring functools.py partial implementation more in line with C 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.
2024-04-17 15:34:46 +02:00
Hugo van Kemenade
7d0be7aea5
Add 'The Python 2.3 Method Resolution Order' ( #116435 )
2024-04-15 13:01:15 +03:00
Furkan Onder
8f5be78bce
gh-72249: Include the module name in the repr of partial object (GH-101910)
...
Co-authored-by: Anilyka Barry <vgr255@live.ca>
2024-02-25 22:55:19 +02:00
Ammar Askar
8b776e0f41
gh-85294: Handle missing arguments to @singledispatchmethod gracefully (GH-21471)
...
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-16 23:17:30 +02:00
Martijn Pieters
edb59d5718
bpo-38364: unwrap partialmethods just like we unwrap partials ( #16600 )
...
* bpo-38364: unwrap partialmethods just like we unwrap partials
The inspect.isgeneratorfunction, inspect.iscoroutinefunction and inspect.isasyncgenfunction already unwrap functools.partial objects, this patch adds support for partialmethod objects as well.
Also: Rename _partialmethod to __partialmethod__.
Since we're checking this attribute on arbitrary function-like objects,
we should use the namespace reserved for core Python.
---------
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-02-15 12:08:45 +01:00
Alex Waygood
40d1de7581
gh-109653: Avoid a top-level import of `types` in `functools` ( #109804 )
2023-09-24 17:18:27 +01:00
Xuehai Pan
74f315edd0
gh-102757: fix function signature mismatch for `functools.reduce` between code and documentation ( #102759 )
2023-09-18 10:42:58 -06:00
Tyler Smart
9bb576cb07
gh-107995: Fix doctest collection of functools.cached_property objects ( #107996 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-18 15:44:38 +00:00
Alex Waygood
2ac103c346
gh-85160: Reduce memory usage of `singledispatchmethod` ( #107706 )
...
A small followup to #107148
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-07 13:46:36 +01:00
Pieter Eendebak
3e334ae259
gh-85160: improve performance of `functools.singledispatchmethod` ( #107148 )
...
Co-authored-by: mental <m3nta1@yahoo.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-08-06 13:37:12 +01:00
Carl Meyer
838406b4fc
gh-106292: restore checking __dict__ in cached_property.__get__ ( #106380 )
...
* gh-106292: restore checking __dict__ in cached_property.__get__
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
2023-07-05 17:01:35 -06:00
Bar Harel
f332594dd4
gh-105172: Fixed functools.lru_cache typed argument docstring. (GH-105173)
2023-05-31 17:56:06 -05:00
Jelle Zijlstra
3fadd7d585
gh-104600: Make function.__type_params__ writable ( #104601 )
2023-05-18 16:45:37 -07:00
Carl Meyer
056dfc71dc
gh-87634: remove locking from functools.cached_property (GH-101890)
...
Remove the undocumented locking capabilities of functools.cached_property.
2023-02-22 17:49:22 -08:00
Serhiy Storchaka
f9433fff47
gh-89828: Do not relay the __class__ attribute in GenericAlias ( #93754 )
...
list[int].__class__ returned type, and isinstance(list[int], type)
returned True. It caused numerous problems in code that checks
isinstance(x, type).
2022-06-18 11:34:57 +03:00
Raymond Hettinger
7ad52d174a
This localization technique is no longer cost effective. (GH-30818)
2022-01-22 20:52:55 -06:00
Serhiy Storchaka
078abb676c
bpo-46032: Check types in singledispatch's register() at declaration time (GH-30050)
...
The registry() method of functools.singledispatch() functions checks now
the first argument or the first parameter annotation and raises a TypeError if it is
not supported. Previously unsupported "types" were ignored (e.g. typing.List[int])
or caused an error at calling time (e.g. list[int]).
2021-12-25 14:16:14 +02:00
Yurii Karabas
3cb357a2e6
bpo-46014: Add ability to use typing.Union with singledispatch (GH-30017)
2021-12-11 00:27:55 +01:00
Raymond Hettinger
1f7d64608b
bpo-44605: Teach @total_ordering() to work with metaclasses (GH-27633)
2021-08-06 14:33:30 -05:00
Noah Kantrowitz
be42c06bb0
Update URLs in comments and metadata to use HTTPS (GH-27458)
2021-07-30 15:54:46 +02:00
Zackery Spytz
cd3c2bdd5d
bpo-31082: Use "iterable" in the docstring for functools.reduce() (GH-20796)
2020-06-28 15:40:54 +09:00
Pablo Galindo
2f172d8f15
bpo-17005: Move topological sort functionality to its own module (GH-20558)
...
The topological sort functionality that was introduced initially in the
functools module has been moved to a new graphlib module to
better accommodate the new tools and keep the original scope of the
functools module.
2020-06-01 00:41:14 +01:00
Raymond Hettinger
21cdb711e3
bpo-40571: Make lru_cache(maxsize=None) more discoverable (GH-20019)
2020-05-11 17:00:53 -07:00
Ethan Smith
cecf049673
bpo-39481: Make functools.cached_property, partial, partialmethod generic ( #19427 )
2020-04-13 21:53:04 -07:00
Nikita Sobolev
bd87a7fda0
Updates functools.py with consistent quotes (GH-18825)
...
I have noticed that `'` quotes are used everywhere except this particular case,
which was introduced in https://github.com/python/cpython/pull/18726
So, this is a trivial fix to enforce better consistency.
2020-03-10 17:32:15 -07:00
MojoVampire
469325c30e
bpo-35712: Make using NotImplemented in a boolean context issue a deprecation warning (GH-13195)
2020-03-03 20:50:17 +02:00
Hakan Çelik
217dce9ee6
bpo-39815: add cached_property to all (GH-18726)
...
Automerge-Triggered-By: @pablogsal
2020-03-01 13:01:34 -08:00
Pablo Galindo
99e6c260d6
bpo-17005: Add a class to perform topological sorting to the standard library (GH-11583)
...
Co-Authored-By: Tim Peters <tim.peters@gmail.com>
2020-01-23 15:29:52 +00:00
Manjusaka
051ff526b5
bpo-38565: add new cache_parameters method for lru_cache (GH-16916)
2019-11-11 23:30:18 -08:00
amist
336b3064d8
Doc: Fix Wikipedia link for functools.lru_cache (GH-16183)
2019-09-16 20:36:14 +02:00
Raymond Hettinger
0dac68f1e5
bpo-36743: __get__ is sometimes called without the owner argument ( #12992 )
2019-08-29 01:27:42 -07:00
Serhiy Storchaka
142566c028
[3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)
...
Turn deprecation warnings added in 3.8 into TypeError.
2019-06-05 18:22:31 +03:00
Serhiy Storchaka
2085bd0877
bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)
2019-06-01 11:00:15 +03:00