{"categories":[{"label":"Software Development","url":"https://skillfed.io/packages/category/software-development/18"}],"enrichment":{"capability":"Provides a method-level caching decorator that stores results per instance, avoiding the need for hashable classes and preventing global cache buildup.","skillfed_tags":["caching","memoization","resource-management"],"use_cases":["Cache expensive GPU operations in tensor-based classes where immediate garbage collection matters.","Memoize method results for non-hashable objects without polluting a global cache.","Cache __hash__ computations for objects that perform costly transfers between devices.","Reduce redundant computation in methods called repeatedly with the same arguments within an instance.","Manage memory-intensive resources that should be freed when their owning object is deleted."],"what_it_does":"cached_method is a decorator that caches method results on a per-instance basis, similar to functools.cached_property but for methods with arguments. Unlike functools.lru_cache applied directly to methods, it does not require the containing class to be hashable, and it does not maintain a global cache that extends object lifetimes. This is particularly useful for classes managing scarce resources like GPU memory, where you want objects and their caches to be garbage-collected together.\n\nThe decorator closely mirrors functools.cached_property's implementation but omits internal locking, accepting the possibility of redundant method calls in multi-threaded contexts when equivalent arguments are used simultaneously. It also supports caching expensive operations like __hash__ without requiring the object itself to be hashable for cache lookups.","worth_installing":"Yes, if you need per-instance method caching for non-hashable classes or resource-intensive objects. The code is simple and stable, but be aware the package is unmaintained since 2021-10-31\u2014verify compatibility with your Python version before relying on it in production. For small hashable objects where global caching is acceptable, the standard functools approach may be preferable."},"id":"cached-method","links":{"html":"https://skillfed.io/packages/cached-method","md":"https://skillfed.io/packages/cached-method.md","pypi":"https://pypi.org/project/cached-method/"},"maintenance":{"status":"abandoned"},"meta":{"latest_release":"2021-10-31","license_spdx":null,"license_treatment":"permissive","name":"cached_method","python_support":"supports_current","summary":"The equivalent of cached_property for methods"},"popularity":{"monthly_downloads":77437,"position":14524,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"0.1.0"}
