[Python-Dev] namedtuple implementation grumble (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Sat Jun 7 16:46:47 CEST 2014


On 7 June 2014 04:50, Chris Withers <chris at simplistix.co.uk> wrote:

Curious as to what lead to that implementation approach? What does it buy that couldn't have been obtained by a mixin providing the functionality?

In principle, you could get the equivalent of collections.namedtuple through dynamically constructed classes. In practice, that's actually easier said than done, so the fact the current implementation works fine for almost all purposes acts as a powerful disincentive to rewriting it. The current implementation is also really easy to understand, while writing out the dynamic type creation explicitly would likely require much deeper knowledge of the type machinery to follow.

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list