classification
Title: let struct's internal cache use FIFO policy
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Ma Lin, inada.naoki, rhettinger
Priority: normal Keywords: patch

Created on 2019-03-30 02:43 by Ma Lin, last changed 2019-03-30 06:58 by rhettinger. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12624 closed Ma Lin, 2019-03-30 02:46
Messages (3)
msg339168 - (view) Author: Ma Lin (Ma Lin) * Date: 2019-03-30 02:43
Currently, when the cache is full, the entire cache is cleared.
This patch let it use FIFO policy.

Inada Naoki, Raymond Hettinger, could you review this patch? Thanks.
No hurry, just do it when you have time.
msg339169 - (view) Author: Ma Lin (Ma Lin) * Date: 2019-03-30 03:11
FYI, re module's cache is using FIFO policy:

https://github.com/python/cpython/blob/v3.8.0a3/Lib/re.py#L288-L293
msg339181 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-03-30 06:58
I don't know that FIFO makessense in the context of how the struct module is typically used.  Also rebuilding structs in cheap so there is very little need for further optimization.  As far as I can tell, no user has ever reported a performance issue with struct (if they had, we could analyze their use case to determine an optimal cache strategy).

So, my preference is to leave the code as-is.
History
Date User Action Args
2019-03-30 06:58:22rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg339181

stage: patch review -> resolved
2019-03-30 03:11:56Ma Linsetmessages: + msg339169
2019-03-30 02:46:11Ma Linsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12558
2019-03-30 02:43:45Ma Lincreate