[issue28239] Implement functools.lru_cache() using ordered dict

2017-12-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Since this theme has been raised again in issue32422 and old patches no longer apply clearly I have updated patches and benchmark results on 64 bit. $ ./python -m perf timeit -s "from functools import lru_cache; f = lru_cache(512)(lambda x: x); a = list(ran

[issue28239] Implement functools.lru_cache() using ordered dict

2017-12-24 Thread Serhiy Storchaka
Change by Serhiy Storchaka : Added file: https://bugs.python.org/file47352/lru_cache-move_to_end-2.patch ___ Python tracker ___ ___ Python-bu

[issue28239] Implement functools.lru_cache() using ordered dict

2017-12-24 Thread Serhiy Storchaka
Change by Serhiy Storchaka : Added file: https://bugs.python.org/file47351/lru_cache-pop-set-2.patch ___ Python tracker ___ ___ Python-bugs-l

[issue28239] Implement functools.lru_cache() using ordered dict

2017-12-24 Thread Serhiy Storchaka
Change by Serhiy Storchaka : Added file: https://bugs.python.org/file47350/lru_cache-get-del-set-2.patch ___ Python tracker ___ ___ Python-bu

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-22 Thread INADA Naoki
INADA Naoki added the comment: FYI: Here is interesting article. doubly-linked list is more inefficient than most people think. http://alex.dzyoba.com/programming/dynamic-arrays.html -- ___ Python tracker

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I don't suggest to change lru_cach() implementation just now For now, I would like to have this closed. It doesn't make sense at the current juncture (with the compact being new, being in flux, and not having guaranteed ordering semantics). Also, we sho

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I consider this issue as lying on the way to using the orderable of dict in OrderedDict implementation (the latter is very desirable because current OrderedDict implementation can be easily broken by using plain dict API). The main difficulty of implementing

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: The problem is that cache hits now create "holes" in the compact dict and trigger periodic compaction. In contrast, the existing code leaves dicts unchanged when there is a cache hit. I prefer the current code. Though it took a little more effort to impl

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : Added file: http://bugs.python.org/file44779/lru_cache-move_to_end.patch ___ Python tracker ___ ___ Python-bugs-

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : Added file: http://bugs.python.org/file44778/lru_cache-pop-set.patch ___ Python tracker ___ ___ Python-bugs-list

[issue28239] Implement functools.lru_cache() using ordered dict

2016-09-21 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: Since dict became ordered, this feature can be used in functools.lru_cache() implementation instead of linked list. This significantly simplifies the code. The first implementation just uses _PyDict_GetItem_KnownHash() + _PyDict_DelItem_KnownHash() + _PyDi