Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:

Other thoughts:

Currently the __getitem__ method is inherited from tuple.  That means
that for normal tuple operations, a named tuple has no performance
penalty (no pure python code is called).  If __getitem__ were
overridden, there would be a substantial additional cost.

Currently, nt[x] raises IndexError if x is not an index a valid range,
but mappings expect a KeyError for missing items.  Switching to a
LookupError would break existing code that catches IndexError.

The collections.Mapping ABC suggests that anything trying to be a
mapping should also provide items(), keys(), values(), and get().  These
don't make much sense for named tuples.

The semantics of __iter__ differ for Mappings and Sequences.  The former
returns keys and the latter returns values.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5205>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to