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 <rep...@bugs.python.org>
<http://bugs.python.org/issue29216>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to