8000 Add a functools.cache variant for methods to avoid keeping instances alive · Issue #102618 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Add a functools.cache variant for methods to avoid keeping instances alive #102618
Open
@stevendaprano

Description

@stevendaprano

functools.cache, when applied to a method, caches the self argument. This can also keep the inst 5F0A ance alive long after it is no longer needed. See for example this discussion.

Following the same API as singledispatch and singledispatchmethod, we should consider adding a cachemethod decorator that either avoids caching self, or uses a weakref for it.

Metadata

Metadata

Assignees

Labels

stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0