[issue29216] Space saving step for the LRU cache

Serhiy Storchaka report at bugs.python.org
Mon Jan 9 12:13:57 EST 2017


Serhiy Storchaka added the comment:

The first patch fails with e.g. tuple subclasses.

The optimization is correct only for types not comparable with tuples. Tuple subclasses are comparable, and classes with custom __eq__ can be comparable. Thus the optimization should be used only for exact builtin types that are known not comparable with tuples. Of course it makes sense only for hashable types.

First than commit something like the second patch I would gather statistics. What are the most used types of the single positional argument of lru-cached functions? Is it worth to apply the optimization for bytes or None? Checking type in C is cheaper than in Python, we can use more types.

----------
assignee: serhiy.storchaka -> rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29216>
_______________________________________


More information about the Python-bugs-list mailing list