Skip to content

Replace custom cached_property with functools.cached_property#11480

Merged
mekarpeles merged 1 commit intomasterfrom
refactor/cached-property
Dec 1, 2025
Merged

Replace custom cached_property with functools.cached_property#11480
mekarpeles merged 1 commit intomasterfrom
refactor/cached-property

Conversation

@cdrini
Copy link
Copy Markdown
Collaborator

@cdrini cdrini commented Nov 17, 2025

Work towards #11479 . This is now built-in to python and can be replaced with functools.cached_property . It was only used in one spot.

Technical

Added in python 3.8, it has the same semantics as our version, namely that it is store for the life time of the instance:

The cached_property decorator only runs on lookups and only when an attribute of the same name doesn’t exist. When it does run, the cached_property writes to the attribute with the same name. Subsequent attribute reads and writes take precedence over the cached_property method and it works like a normal attribute.

Testing

Screenshot

Stakeholders

Copilot AI review requested due to automatic review settings November 17, 2025 22:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the codebase by replacing a custom cached_property implementation with Python's standard library functools.cached_property (available since Python 3.8).

  • Removes the custom cached_property decorator function (22 lines of code)
  • Updates the single usage in MemcacheCache.memcache to use functools.cached_property
  • Removes cached_property from the module's __all__ exports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cdrini cdrini mentioned this pull request Nov 17, 2025
1 task
@mekarpeles mekarpeles merged commit 1e8486f into master Dec 1, 2025
14 checks passed
@mekarpeles mekarpeles self-assigned this Dec 1, 2025
@cdrini cdrini deleted the refactor/cached-property branch December 1, 2025 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants