This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: functools.cached_property should support partial functions and partialmethod's
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Ricardo Branco, carljm, sir-sigurd, taleinat
Priority: normal Keywords: patch

Created on 2019-10-18 13:18 by Ricardo Branco, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16838 closed python-dev, 2019-10-18 13:47
Messages (4)
msg354893 - (view) Author: Ricardo Branco (Ricardo Branco) * Date: 2019-10-18 13:18
functools.cached_property should support partial functions and partialmethod's

This way one can create cached_property's dynamically.
msg355121 - (view) Author: Sergey Fedoseev (sir-sigurd) * Date: 2019-10-22 08:06
issue38524 is related.
msg356537 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2019-11-13 16:03
Note that it is already possible, though awkward, to create cached properties dynamically. Using the example from PR GH-16838:

class ProcNet:

for proto in ('icmp', 'icmp6', 'raw', 'raw6', 'tcp', 'tcp6', 'udp', 'udp6', 'udplite', 'udplite6'):
    def prop(self, *, proto=proto):
        with open(os.path.join("/proc/net", proto)) as file:
    setattr(ProcNet, proto, prop)
    prop.__set_name__(ProcNet, proto)

IMO this is good enough, considering that this is all pretty much required for dynamically creating normal (uncached) properties and other types of descriptors.
msg356538 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2019-11-13 16:10
According to issue38524, this should be closed.
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82698
2019-11-13 16:10:31taleinatsetstatus: open -> closed
resolution: wont fix
stage: patch review -> resolved
2019-11-13 16:10:19taleinatsetmessages: + msg356538
2019-11-13 16:03:00taleinatsetnosy: + taleinat
messages: + msg356537
2019-10-22 08:06:56sir-sigurdsetnosy: + sir-sigurd
messages: + msg355121
2019-10-18 13:47:43python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16386
2019-10-18 13:42:54xtreaksetnosy: + carljm
2019-10-18 13:18:33Ricardo Brancocreate