Help on module functools: NAME functools - functools.py - Tools for working with functions and callable objects MODULE REFERENCE https://docs.python.org/3.12/library/functools.html The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above. CLASSES builtins.object cached_property partial partialmethod singledispatchmethod class cached_property(builtins.object) | cached_property(func) | | Methods defined here: | | __get__(self, instance, owner=None) | | __init__(self, func) | Initialize self. See help(type(self)) for accurate signature. | | __set_name__(self, owner, name) | | ---------------------------------------------------------------------- | Class methods defined here: | | __class_getitem__ = GenericAlias(...) | Represent a PEP 585 generic type | | E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object class partial(builtins.object) | partial(func, *args, **keywords) - new function with partial application | of the given arguments and keywords. | | Methods defined here: | | __call__(self, /, *args, **kwargs) | Call self as a function. | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | ---------------------------------------------------------------------- | Class methods defined here: | | __class_getitem__(...) | See PEP 585 | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | | __vectorcalloffset__ | | args | tuple of arguments to future partial calls | | func | function object to use in future partial calls | | keywords | dictionary of keyword arguments to future partial calls class partialmethod(builtins.object) | partialmethod(func, /, *args, **keywords) | | Method descriptor with partial application of the given arguments | and keywords. | | Supports wrapping existing descriptors and handles non-descriptor | callables as instance methods. | | Methods defined here: | | __get__(self, obj, cls=None) | | __init__(self, func, /, *args, **keywords) | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) | Return repr(self). | | ---------------------------------------------------------------------- | Class methods defined here: | | __class_getitem__ = GenericAlias(...) | Represent a PEP 585 generic type | | E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,). | | ---------------------------------------------------------------------- | Readonly properties defined here: | | __isabstractmethod__ | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object class singledispatchmethod(builtins.object) | singledispatchmethod(func) | | Single-dispatch generic method descriptor. | | Supports wrapping existing descriptors and handles non-descriptor | callables as instance methods. | | Methods defined here: | | __get__(self, obj, cls=None) | | __init__(self, func) | Initialize self. See help(type(self)) for accurate signature. | | register(self, cls, method=None) | generic_method.register(cls, func) -> func | | Registers a new implementation for the given *cls* on a *generic_method*. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | __isabstractmethod__ | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object FUNCTIONS cache(user_function, /) Simple lightweight unbounded cache. Sometimes called "memoize". cmp_to_key(mycmp) Convert a cmp= function into a key= function. mycmp Function that compares two objects. lru_cache(maxsize=128, typed=False) Least-recently-used cache decorator. If *maxsize* is set to None, the LRU features are disabled and the cache can grow without bound. If *typed* is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated as distinct calls with distinct results. Arguments to the cached function must be hashable. View the cache statistics named tuple (hits, misses, maxsize, currsize) with f.cache_info(). Clear the cache and statistics with f.cache_clear(). Access the underlying function with f.__wrapped__. See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU) reduce(...) reduce(function, iterable[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence or iterable, from left to right, so as to reduce the iterable to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the iterable in the calculation, and serves as a default when the iterable is empty. singledispatch(func) Single-dispatch generic function decorator. Transforms a function into a generic function, which can have different behaviours depending upon the type of its first argument. The decorated function acts as the default implementation, and additional implementations can be registered using the register() attribute of the generic function. total_ordering(cls) Class decorator that fills in missing ordering methods update_wrapper(wrapper, wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__'), updated=('__dict__',)) Update a wrapper function to look like the wrapped function wrapper is the function to be updated wrapped is the original function assigned is a tuple naming the attributes assigned directly from the wrapped function to the wrapper function (defaults to functools.WRAPPER_ASSIGNMENTS) updated is a tuple naming the attributes of the wrapper that are updated with the corresponding attribute from the wrapped function (defaults to functools.WRAPPER_UPDATES) wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__'), updated=('__dict__',)) Decorator factory to apply update_wrapper() to a wrapper function Returns a decorator that invokes update_wrapper() with the decorated function as the wrapper argument and the arguments to wraps() as the remaining arguments. Default arguments are as for update_wrapper(). This is a convenience function to simplify applying partial() to update_wrapper(). DATA WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__qualname__', '__do... WRAPPER_UPDATES = ('__dict__',) __all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_... FILE /usr/lib/python3.12/functools.py
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-01 17:37 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)