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
Raymond Hettinger
b821868e6d
bpo-36772 Allow lru_cache to be used as decorator without making a function call (GH-13048)
2019-05-26 11:27:35 -07:00
Lysandros Nikolaou
d673810b9d
bpo-35252: Remove FIXME from test_functools (GH-10551)
2019-05-19 15:11:20 -07:00
Serhiy Storchaka
d53cf99dca
bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705)
2019-05-06 22:40:27 +03:00
Serhiy Storchaka
42a139ed88
bpo-36492: Deprecate passing some arguments as keyword arguments. (GH-12637)
...
Deprecated passing the following arguments as keyword arguments:
- "func" in functools.partialmethod(), weakref.finalize(),
profile.Profile.runcall(), cProfile.Profile.runcall(),
bdb.Bdb.runcall(), trace.Trace.runfunc() and
curses.wrapper().
- "function" in unittest.addModuleCleanup() and
unittest.TestCase.addCleanup().
- "fn" in the submit() method of concurrent.futures.ThreadPoolExecutor
and concurrent.futures.ProcessPoolExecutor.
- "callback" in contextlib.ExitStack.callback(),
contextlib.AsyncExitStack.callback() and
contextlib.AsyncExitStack.push_async_callback().
- "c" and "typeid" in the create() method of multiprocessing.managers.Server
and multiprocessing.managers.SharedMemoryServer.
- "obj" in weakref.finalize().
Also allowed to pass arbitrary keyword arguments (even "self" and "func")
if the above arguments are passed as positional argument.
2019-04-01 09:16:35 +03:00
Serhiy Storchaka
da0847048a
bpo-36431: Use PEP 448 dict unpacking for merging two dicts. (GH-12553)
2019-03-27 08:02:28 +02:00
Raymond Hettinger
ffdf1c30ab
Consistently move the misses update to just before the user function call (GH-11715)
2019-01-31 15:03:38 -08:00
Raymond Hettinger
d8080c0119
bpo-35780: Fix errors in lru_cache() C code (GH-11623)
2019-01-26 03:02:00 -05:00
Pablo Galindo
7cd2543416
bpo-34890: Make iscoroutinefunction, isgeneratorfunction and isasyncgenfunction work with functools.partial (GH-9903)
...
inspect.isfunction() processes both inspect.isfunction(func) and
inspect.isfunction(partial(func, arg)) correctly but some other functions in the
inspect module (iscoroutinefunction, isgeneratorfunction and isasyncgenfunction)
lack this functionality. This commits adds a new check in the mentioned functions
in the inspect module so they can work correctly with arbitrarily nested partial
functions.
2018-10-26 12:19:14 +01:00
madman-bob
e25d5fc18e
bpo-32321: Add pure Python fallback for functools.reduce (GH-8548)
2018-10-25 16:02:10 +02:00
Carl Meyer
d658deac60
bpo-21145: Add cached_property decorator in functools ( #6982 )
...
Robust caching of calculated properties is
harder than it looks at first glance, so add
a solid, well-tested implementation to the
standard library.
2018-08-28 17:11:56 +10:00
Dong-hee Na
445f1b35ce
bpo-33967: Fix singledispatch raised IndexError when no args (GH-8184)
2018-07-10 16:26:36 +09:00
Ethan Smith
c651275afe
bpo-32380: Create functools.singledispatchmethod ( #6306 )
2018-05-26 13:38:33 -07:00
Łukasz Langa
e56975351b
bpo-32227: functools.singledispatch supports registering via type annotations ( #4733 )
2017-12-11 13:56:31 -08:00