Uh oh!
There was an error while loading. Please reload this page.
gh-64373: Convert _functools to Argument Clinic - #96640
Conversation
sobolevn
commented
Sep 7, 2022
Now, let's compare cmp_to_keyBefore: >>>help(_functools.cmp_to_key)
Helponbuilt-infunctioncmp_to_keyinmodule_functools:
cmp_to_key(...)
Convertacmp=functionintoakey=function.After: >>>help(_functools.cmp_to_key)
Helponbuilt-infunctioncmp_to_keyinmodule_functools:
cmp_to_key(mycmp)
Convertacmp=functionintoakey=function.
mycmpFunctionthatcomparestwoobjects._lru_cache_wrapperBefore: >>>help(_functools._lru_cache_wrapper)
Helponclass_lru_cache_wrapperinmodulefunctools:
class_lru_cache_wrapper(builtins.object)
|Createacachedcallablethatwrapsanotherfunction.
||user_function: thefunctionbeingcached||maxsize: 0fornocaching|Noneforunlimitedcachesize|nforaboundedcache||typed: Falsecachef(3) andf(3.0) asidenticalcalls|Truecachef(3) andf(3.0) asdistinctcalls||cache_info_type: namedtupleclasswiththefields:
|hitsmissescurrsizemaxsize||Methodsdefinedhere:After: >>>help(_functools._lru_cache_wrapper)
Helponclass_lru_cache_wrapperinmodulefunctools:
class_lru_cache_wrapper(builtins.object)
|_lru_cache_wrapper(user_function, maxsize, typed, cache_info_type)
||Createacachedcallablethatwrapsanotherfunction.
||user_function|thefunctionbeingcached|maxsize|0fornocaching|Noneforunlimitedcachesize|nforaboundedcache|typed|Falsecachef(3) andf(3.0) asidenticalcalls|Truecachef(3) andf(3.0) asdistinctcalls|cache_info_type|namedtupleclasswiththefields:
|hitsmissescurrsizemaxsize||Methodsdefinedhere:
|
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 |
sobolevn
commented
Sep 7, 2022
Thank you for the insight! This is my first clinic-related PR. I will remove things like
I think that |
rhettinger
commented
Sep 8, 2022
You can change those two zero-argument methods if you want. |
Uh oh!
There was an error while loading. Please reload this page.
bedevere-bot
commented
Sep 9, 2022
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 |
sobolevn
commented
Sep 12, 2022
I have made the requested changes; please review again |
bedevere-bot
commented
Sep 12, 2022
Thanks for making the requested changes! @rhettinger: please review the changes made to this pull request. |
A couple of extra notes:
functools.reduceis not converted, because itsargsparsing / in-place mutation is optimizedpartial_newandpartial_callrequire*args, **kwargs, as far as I know AC does not support that at the moment, they are not converted_lru_cache_wrapper.__call__