Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var KeyObjectType = objects.NewType("functools.KeyWrapper", []*objects.Type{objects.ObjectType()})
KeyObjectType is the keyobject class returned by cmp_to_key. Each instance carries the user's cmp function plus an obj; rich comparisons call cmp(self.obj, other.obj) and compare the integer result to zero.
CPython: Modules/_functoolsmodule.c:881 keyobject_type_spec
var LruCacheWrapperType = newLruCacheWrapperType()
LruCacheWrapperType is functools._lru_cache_wrapper. Instances are callable wrappers around a user function plus a key->result cache and an LRU recency list when maxsize is bounded.
CPython: Modules/_functoolsmodule.c:1810 lru_cache_type_spec
var PartialType = newPartialType()
PartialType is functools.partial. Instances bundle a callable with a frozen prefix of positional and keyword arguments; calling the partial spreads those plus the call-site args into the underlying function. Placeholder sentinels in args reserve slots that the call site fills in left-to-right.
CPython: Modules/_functoolsmodule.c:796 partial_type_spec
var Placeholder objects.Object
Placeholder is the singleton instance of PlaceholderType, mirroring the module-level Placeholder attribute set in _functools_exec.
CPython: Modules/_functoolsmodule.c:1848 Placeholder
var PlaceholderType = objects.NewType("_PlaceholderType", []*objects.Type{objects.ObjectType()})
PlaceholderType backs functools.Placeholder. CPython exposes a singleton instance whose only purpose is to act as a sentinel inside partial.args (and to be checked by identity).
CPython: Modules/_functoolsmodule.c:128 placeholder_type_spec
Functions ¶
This section is empty.
Types ¶
type LruCacheWrapper ¶
type LruCacheWrapper struct {
objects.Header
Func objects.Object
Maxsize int64
Unbounded bool // true when maxsize is None.
Typed bool
Cache *objects.Dict
CacheInfoType objects.Object
Hits int64
Misses int64
// Per-instance attribute dict for user assignments like
// `wrapper.cache_parameters = lambda ...` that lru_cache() makes.
// Lazily allocated.
Dict *objects.Dict
// contains filtered or unexported fields
}
LruCacheWrapper is the runtime shape of an _lru_cache_wrapper. It folds the dict cache plus the doubly-linked recency list plus the hit/miss counters; see the C struct lru_cache_object for the CPython side.
CPython: Modules/_functoolsmodule.c:1120 lru_cache_object
type Partial ¶
type Partial struct {
objects.Header
Fn objects.Object
Args *objects.Tuple
Keywords *objects.Dict
Dict *objects.Dict
Phcount int
}
Partial is the concrete Go shape backing a partial instance. The fields mirror partialobject in the C source.
CPython: Modules/_functoolsmodule.c:136 partialobject