You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/rhettinger'closed_at=<Date2011-10-20.15:59:28.817>created_at=<Date2011-10-19.22:06:36.315>labels= ['type-feature', 'library']
title='Option to make the lru_cache type specific'updated_at=<Date2011-10-20.15:59:28.815>user='https://github.com/rhettinger'
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.
Activity
rhettinger commentedon Oct 19, 2011
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:
Without type specificity, all four calls will return 9 rather than 9. 9.0, 9, 9.0.
First-pass patch attached.
rhettinger commentedon Oct 19, 2011
Updated patch to include tests and an application to the re module.
vstinner commentedon Oct 19, 2011
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).
ncoghlan commentedon Oct 20, 2011
Features looks good, but the current patch doesn't handle keyword arguments correctly (more details in the Reitveld review).
rhettinger commentedon Oct 20, 2011
Nick, Ezio, and Victor, thanks for looking at the code.
Here's an updated the patch:
ncoghlan commentedon Oct 20, 2011
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-dev commentedon Oct 20, 2011
New changeset cba503a2c468 by Raymond Hettinger in branch 'default':
bpo-13227: Option to make the lru_cache() type specific (suggested by Andrew Koenig).
http://hg.python.org/cpython/rev/cba503a2c468
rhettinger commentedon Oct 20, 2011
Victor, Ezio, and Nick, thanks for the review.
Andrew, thanks for the feature request.