-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-64373: Convert _functools
to Argument Clinic
#96640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Now, let's compare cmp_to_keyBefore: >>> help(_functools.cmp_to_key)
Help on built-in function cmp_to_key in module _functools:
cmp_to_key(...)
Convert a cmp= function into a key= function. After: >>> help(_functools.cmp_to_key)
Help on built-in function cmp_to_key in module _functools:
cmp_to_key(mycmp)
Convert a cmp= function into a key= function.
mycmp
Function that compares two objects. _lru_cache_wrapperBefore: >>> help(_functools._lru_cache_wrapper)
Help on class _lru_cache_wrapper in module functools:
class _lru_cache_wrapper(builtins.object)
| Create a cached callable that wraps another function.
|
| user_function: the function being cached
|
| maxsize: 0 for no caching
| None for unlimited cache size
| n for a bounded cache
|
| typed: False cache f(3) and f(3.0) as identical calls
| True cache f(3) and f(3.0) as distinct calls
|
| cache_info_type: namedtuple class with the fields:
| hits misses currsize maxsize
|
| Methods defined here: After: >>> help(_functools._lru_cache_wrapper)
Help on class _lru_cache_wrapper in module functools:
class _lru_cache_wrapper(builtins.object)
| _lru_cache_wrapper(user_function, maxsize, typed, cache_info_type)
|
| Create a cached callable that wraps another function.
|
| user_function
| the function being cached
| maxsize
| 0 for no caching
| None for unlimited cache size
| n for a bounded cache
| typed
| False cache f(3) and f(3.0) as identical calls
| True cache f(3) and f(3.0) as distinct calls
| cache_info_type
| namedtuple class with the fields:
| hits misses currsize maxsize
|
| Methods defined here:
|
We generally only apply argclinic to functions directly visible to the user. Otherwise, it is mostly pointless since no one sees the signature. So, I would leave the lru cache internals alone -- iirc, we had an issue for this previously. It was would be a lot of code churn for no benefit. The |
Thank you for the insight! This is my first clinic-related PR. I will remove things like
I think that |
You can change those two zero-argument methods if you want. |
adef1a2
to
79fa9e8
Compare
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again |
Thanks for making the requested changes! @rhettinger: please review the changes made to this pull request. |
A couple of extra notes:
functools.reduce
is not converted, because itsargs
parsing / in-place mutation is optimizedpartial_new
andpartial_call
require*args, **kwargs
, as far as I know AC does not support that at the moment, they are not converted_lru_cache_wrapper.__call__