[issue44310] Document that lru_cache uses hard references

2021-06-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Adding a weak referencing recipe here just so I can find it in the future. -- import functools import weakref def weak_lru(maxsize=128, typed=False): """LRU Cache decorator that

[issue44310] Document that lru_cache uses hard references

2021-06-18 Thread Raymond Hettinger
Change by Raymond Hettinger : -- pull_requests: +25373 pull_request: https://github.com/python/cpython/pull/26789 ___ Python tracker ___

[issue44310] Document that lru_cache uses hard references

2021-06-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 77eaf14d278882857e658f83681e5b9a52cf14ac by Miss Islington (bot) in branch '3.10': bpo-44310: Add a FAQ entry for caching method calls (GH-26731) (GH-26777) https://github.com/python/cpython/commit/77eaf14d278882857e658f83681e5b9a52cf14ac

[issue44310] Document that lru_cache uses hard references

2021-06-17 Thread miss-islington
Change by miss-islington : -- pull_requests: +25363 pull_request: https://github.com/python/cpython/pull/26777 ___ Python tracker ___

[issue44310] Document that lru_cache uses hard references

2021-06-17 Thread miss-islington
Change by miss-islington : -- pull_requests: +25364 pull_request: https://github.com/python/cpython/pull/26778 ___ Python tracker ___

[issue44310] Document that lru_cache uses hard references

2021-06-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 7f01f77f8fabcfd7ddb5d99f12d6fc99af9af384 by Raymond Hettinger in branch 'main': bpo-44310: Add a FAQ entry for caching method calls (GH-26731) https://github.com/python/cpython/commit/7f01f77f8fabcfd7ddb5d99f12d6fc99af9af384 --

[issue44310] Document that lru_cache uses hard references

2021-06-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I meant, if one has set maxsize=None. The docs already say, "If maxsize is set to None, the LRU feature is disabled and the cache can grow without bound." -- ___ Python tracker

[issue44310] Document that lru_cache uses hard references

2021-06-17 Thread Henk-Jaap Wagenaar
Henk-Jaap Wagenaar added the comment: (but consenting adults, setting max_size=None for "efficiency", you better be sure what you are doing in a long running process and making sure it cannot grow unbounded.) -- ___ Python tracker

[issue44310] Document that lru_cache uses hard references

2021-06-17 Thread Henk-Jaap Wagenaar
Henk-Jaap Wagenaar added the comment: I clearly was missing some words there Raymond. I meant, if one has set maxsize=None. -- ___ Python tracker ___

[issue44310] Document that lru_cache uses hard references

2021-06-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: > if you are creating instances and calling this method > all the time, will lead to an infinite memory leak. Your words aren't making any sense to me. The default lru_cache will never hold more than maxsize entries. The default maxsize is 128. How is

[issue44310] Document that lru_cache uses hard references

2021-06-16 Thread Henk-Jaap Wagenaar
Henk-Jaap Wagenaar added the comment: PR 26731 looks very good to me. My only comment, which I am not sure is worthy of adding/is a general lru_cache thing, that "instances are kept alive until they age out of the cache or until the cache is cleared", if you are creating instances and calling

[issue44310] Document that lru_cache uses hard references

2021-06-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: See PR 26731 for a draft FAQ entry. Let me know what you think. -- ___ Python tracker ___

[issue44310] Document that lru_cache uses hard references

2021-06-15 Thread Raymond Hettinger
Change by Raymond Hettinger : -- pull_requests: +25319 pull_request: https://github.com/python/cpython/pull/26731 ___ Python tracker ___

[issue44310] Document that lru_cache uses hard references

2021-06-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset 809c3faa032d32bc45a0fa54d0400fcbc42a618f by Miss Islington (bot) in branch '3.10': bpo-44310: Note that lru_cache keep references to both arguments and results (GH-26715) (GH-26716)

[issue44310] Document that lru_cache uses hard references

2021-06-13 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: duplicate -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue44310] Document that lru_cache uses hard references

2021-06-13 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 8.0 -> 9.0 pull_requests: +25304 pull_request: https://github.com/python/cpython/pull/26716 ___ Python tracker

[issue44310] Document that lru_cache uses hard references

2021-06-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: New changeset fafcfff9262ae9dee03a6638dfcbcfc23a7b by Raymond Hettinger in branch 'main': bpo-44310: Note that lru_cache keep references to both arguments and results (GH-26715)

[issue44310] Document that lru_cache uses hard references

2021-06-13 Thread Raymond Hettinger
Change by Raymond Hettinger : -- pull_requests: +25303 pull_request: https://github.com/python/cpython/pull/26715 ___ Python tracker ___

[issue44310] Document that lru_cache uses hard references

2021-06-08 Thread Henk-Jaap Wagenaar
Henk-Jaap Wagenaar added the comment: Reading this bug thread last week made me realize we had made the following error in our code: class SomethingView(): @functools.lru_cache() def get_object(self): return self._object Now, as this class was instantiated for every

[issue44310] Document that lru_cache uses hard references

2021-06-05 Thread Joannah Nanjekye
Joannah Nanjekye added the comment: I saw the thread but the idea was rejected by @rhettinger who seems to suggest the changes in the documentation this time himself. Maybe he has changed his mind, in which case he can explain the circumstances of his decisions if he wants. --

[issue44310] Document that lru_cache uses hard references

2021-06-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This is a full duplicate of issue19859. Both ideas of using weak references and changing documentation were rejected. -- nosy: +serhiy.storchaka resolution: -> duplicate superseder: -> functools.lru_cache keeps objects alive forever

[issue44310] Document that lru_cache uses hard references

2021-06-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: It may useful to link back to @cached_property() for folks wanting method caching tied to the lifespan of an instance rather than actual LRU logic. -- ___ Python tracker

[issue44310] Document that lru_cache uses hard references

2021-06-04 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Agreed! I will let the PR to you :) -- ___ Python tracker ___ ___ Python-bugs-list

[issue44310] Document that lru_cache uses hard references

2021-06-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm thinking of a more minimal and targeted edit than what is in the PR. Per the dev guide, we usually word the docs in an affirmative and specific manner (here is what the tool does and an example of how to use it). Recounting a specific debugging

[issue44310] Document that lru_cache uses hard references

2021-06-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: Also note that many important objects in Python are not weak referenceable, tuples for example. -- title: lru_cache memory leak -> Document that lru_cache uses hard references ___ Python tracker