[Python-Dev] Impact of Namedtuple on startup time

MRAB python at mrabarnett.plus.com
Mon Jul 17 16:57:24 EDT 2017


On 2017-07-17 21:46, MRAB wrote:
> On 2017-07-17 21:31, Giampaolo Rodola' wrote:
>> I completely agree. I love namedtuples but I've never been too happy 
>> about the additional overhead vs. plain tuples (both for creation and 
>> attribute access times), to the point that I explicitly avoid to use 
>> them in certain circumstances (e.g. a busy loop) and only for public 
>> end-user APIs returning multiple values.
>> 
>> To be entirely honest, I'm not even sure why they need to be forcefully 
>> declared upfront in the first place, instead of just having a 
>> first-class function (builtin?) written in C:
>> 
>>  >>> ntuple(x=1, y=0)
>> (x=1, y=0)
>> 
>> ...or even a literal as in:
>> 
>>  >>> (x=1, y=0)
>> (x=1, y=0)
>> 
> [snip]
> 
> I know it's a bit early to bikeshed, but shouldn't that be:
> 
>   >>> (x: 1, y: 0)
> (x: 1, y: 0)
> 
> instead if it's a display/literal?
> 
Actually, come to think of it, a dict's keys would be quoted, so there 
would be a slight inconsistency there...


More information about the Python-Dev mailing list