[issue13227] Option to make the lru_cache type specific
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset cba503a2c468 by Raymond Hettinger in branch 'default': Issue 13227: Option to make the lru_cache() type specific (suggested by Andrew Koenig). http://hg.python.org/cpython/rev/cba503a2c468 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13227] Option to make the lru_cache type specific
Raymond Hettinger raymond.hettin...@gmail.com added the comment: Victor, Ezio, and Nick, thanks for the review. Andrew, thanks for the feature request. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13227] Option to make the lru_cache type specific
New submission from Raymond Hettinger raymond.hettin...@gmail.com: Based on a comment from Andrew Koenig, it is suggested that the lru_cache() offer an option to become type specific so that equal objects of different typed don't get cached to the same entry. Here's an example: @lru_cache(typed=True) def square(x): print('squaring', x) return x * x for x in [3, 3.0, 3, 3.0]: print(square(x)) Without type specificity, all four calls will return 9 rather than 9. 9.0, 9, 9.0. First-pass patch attached. -- assignee: rhettinger components: Library (Lib) files: typed_lru.diff keywords: patch messages: 145976 nosy: rhettinger priority: low severity: normal status: open title: Option to make the lru_cache type specific type: feature request versions: Python 3.3 Added file: http://bugs.python.org/file23473/typed_lru.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13227] Option to make the lru_cache type specific
Raymond Hettinger raymond.hettin...@gmail.com added the comment: Updated patch to include tests and an application to the re module. -- Added file: http://bugs.python.org/file23475/typed_lru2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13227] Option to make the lru_cache type specific
STINNER Victor victor.stin...@haypocalc.com added the comment: The patch doesn't update the doc. You may also test type(square(3)). Except of these nits, the patch looks good. The typed option is an important feature, and your patch contains a good example of its usage (the re module). -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13227] Option to make the lru_cache type specific
Nick Coghlan ncogh...@gmail.com added the comment: Features looks good, but the current patch doesn't handle keyword arguments correctly (more details in the Reitveld review). -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13227] Option to make the lru_cache type specific
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13227] Option to make the lru_cache type specific
Raymond Hettinger raymond.hettin...@gmail.com added the comment: Nick, Ezio, and Victor, thanks for looking at the code. Here's an updated the patch: * optimization for fast globals() are now keyword-only arguments * now types the keyword values, not the key/values tuples * expanded tests * added the doc update -- Added file: http://bugs.python.org/file23480/typed_lru3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13227] Option to make the lru_cache type specific
Nick Coghlan ncogh...@gmail.com added the comment: Looks good to me (although it took me longer than it should have to figure out why you didn't need to store the keyword argument names a second time) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com