Joe Jevnik added the comment:

Ideally, namedtuple is used to make your code cleaner, using "magic" indecies 
is less clear than using a named index in a lot of cases. Because namedtuple is 
mainly to make the code more readable, I don't think that it should have an 
impact on the runtime performance of the code. This means that namedtuple 
should be a very thin wrapper around tuple. Currently, namedtuple named item 
access is much slower than elementwise access. I have this as a standalone 
package (there are some changes in the diff I posted to acheive full backwards 
compat) here https://pypi.python.org/pypi/cnamedtuple/0.1.5 that show some 
profiling runs of this code. The notable one to me is named item access being 
around twice as fast.

Another issue we ran into at work is that we found ways to get the exec call in 
nametuple to execute arbitrary code; while this would not be a concern for most 
people by the nature of the way we got this to happen, we wanted to look at 
other ways of writing namedtuple. I looked through some older discussion and 
found that non-exec solutions were rejected in the past for perfomance reasons.

----------

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

Reply via email to