Re:Grumpy: Go running Python
by beagle3 on Wednesday January 04, 2017 @04:10PM
(#13322070)
namedtuples are tuples, meaning they are stored efficiently, and are constant (thus can also be used as dictionary keys). Unlike regular tuples, they can be accessed like a class/dictionary for readability, but requiring much less allocations (compared to dict/class), so much faster. Also, as they are tuples, you have well defined methods (printing, comparison, hash value, ) you'd have to implement yourself for dict/class.
If you like writing in functional style, namedtuples are much more natural than dict or classes, and more efficient to boot.
If you like writing in functional style, namedtuples are much more natural than dict or classes, and more efficient to boot.