Opened 11 years ago
Closed 11 years ago
#22691 closed New feature (fixed)
Allow cached_property to be used on other methods
Description (last modified by ) ¶
This adds an optional name property to cached_property, overriding where it stores its cached value.
class Foo(object): def get_bar(self): ...heavy work... bar = cached_property(get_bar, name='bar')
Without the name, it would save the result in __dict__['get_bar']
, thus masking the method.
Change History (4)
comment:1 by , 11 years ago
Cc: | added |
---|---|
Description: | modified (diff) |
Has patch: | set |
Needs documentation: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
Version: | 1.6 → master |
Version 0, edited 11 years ago by (next)
comment:2 by , 11 years ago
Actually, #22663 suggests to remove the documentation for cached_property
. Second opinions welcome on that...
comment:3 by , 11 years ago
Needs documentation: | unset |
---|---|
Patch needs improvement: | unset |
I added docs in a comment on the PR; will go ahead and commit this if they look okay.
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Sounds good.
Since
cached_property
is documented, it'll need docs update and release notes.