Re:Lesser known parts of Python standard library – Trickster...
by d0mine on Thursday September 05, 2024 @02:31AM
(#41454120)
It may be more explicit: OrderedDict has move_to_end() which may be useful e.g., for implementing lru_cache-like functionality (like deque.rotate but with arbitrary keys).
[ Parent
| on HN ]
Re:Lesser known parts of Python standard library – Trickster...
by masklinn on Thursday September 05, 2024 @05:18AM
(#41454937)
OTOH that’s a lot less useful now that functools.lru_cache exists: it’s more specialised so it’s lighter, more efficient, and thread-safe. So unless you have extended flexibility requirements around your LRU, OD loses a lot there.
And if you’re using a FIFO cache, threading a regular dict through a separate fifo (whether linked list or deque) is more efficient in my experience of implementing both S3 and Sieve.