[issue7224] One obvious way to do interning

Raymond Hettinger report at bugs.python.org
Thu Nov 5 21:23:36 CET 2009


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

That is a false optimization.  Regular python code is full of look-ups
(even set.add has a getattr(s, 'add') lookup just to find the
add-method; every call to a built-in typically goes through multiple
lookups).   Also, the cost of a second lookup is trivial because of
processor caching:  see Object/dictnotes.txt.

Martin has already rejected a similar proposal for similar reasons. 
Please drop this one.  IMO, it is harmful to the set API because it
changes set's core concept to include lookup operations instead of just
simple set operations.

Either use sys.intern() or roll your own using get_equivalent() or a
dictionary.  A single use-case doesn't warrant building-out the
language, providing more ways to do it, or messing the core concept of
the set/frozenset datatype.

----------

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


More information about the Python-bugs-list mailing list