FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-116946: fully implement GC protocol for `_functools._lru_list_elem` by picnixz · Pull Request #138334 · python/cpython · GitHub

/ cpython Public

gh-116946: fully implement GC protocol for _functools._lru_list_elem - #138334

Closed
picnixz wants to merge 1 commit into
python:mainfrom
picnixz:fix/gc/functools-heap-types-116946
Closed

gh-116946: fully implement GC protocol for _functools._lru_list_elem#138334
picnixz wants to merge 1 commit into
python:mainfrom
picnixz:fix/gc/functools-heap-types-116946

Conversation

picnixz commented Sep 1, 2025
edited
Loading

Copy link
Copy Markdown
Member

This type is immutable but it is a true container type, so it needs the GC. However I need to measure performances.

This comment was marked as resolved.

picnixz commented Sep 1, 2025

Copy link
Copy Markdown
Member Author

Oh there is a previous discussion: #76603. I'll check this.

picnixz force-pushed the fix/gc/functools-heap-types-116946 branch from f4151b8 to 9b04072 Compare September 1, 2025 11:20

picnixz commented Sep 1, 2025

Copy link
Copy Markdown
Member Author

Mmh, so this now boils down to whether we want to make sure that the GC protocol is correctly implemented or if we want to keep performances.

rhettinger commented Sep 1, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

The lru_cache_type_spec already is marked with Py_TPFLAGS_HAVE_GC and Py_TPFLAGS_IMMUTABLETYPE. And the lru_cache_tp_traverse is already visiting all of the _lru_list_elem entries. ISTM that all parts that can hold an object are already visible to GC and would be collected at shutdown. This PR seems unnecessary and will just hurt performance for no real use benefit.

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Concur with @rhettinger.

Note also that the cache dict is already visited, and it visits all its elements, so they will be visited twice with this PR.

Also, clearing the key in lru_list_elem_clear() can have bad consequences.

picnixz commented Sep 1, 2025

Copy link
Copy Markdown
Member Author

I see. Ok I'll close this one and will just change the immutability bit when necessary in the other PRs.

picnixz closed this Sep 1, 2025
picnixz deleted the fix/gc/functools-heap-types-116946 branch October 11, 2025 14:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL