这个是正解。
functools.cache文档:
Returns the same as lru_cache(maxsize=None)
... never needs to evict old values ...
本来就不适合楼主这种场景使用的。
【 在 xuanqing 的大作中提到: 】
: 标 题: Re: 请教个内存占用的问题
: 发信站: 水木社区 (Mon Oct 13 17:43:44 2025), 转信
:
: 改用@functools.lru_cache试试
: 至少可以设一下maxsize
:
:
: 【 在 pcal 的大作中提到: 】
: : 我有段代码,逻辑总结起来比较简单:
: : @functools.cache
: : def a_long_time_calc(cis):
: : ...................
:
: --
:
: ※ 来源:·水木社区 mysmth.net·[FROM: 123.123.203.*]
--
FROM 101.87.0.*