Re: [PATCH net 5/5] selftests: net-drv: stats: sanity check netlink dumps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 16 Dec 2024 11:53:58 +0100 Petr Machata wrote:
> > +        if ifindex not in parsed:
> > +            parsed[ifindex] = {"rx":[], "tx": []}
> > +        parsed[ifindex][entry["queue-type"]].append(entry['queue-id'])  
> 
> BTW setdefault() exists for exactly these add-unless-already-exists
> scenarios:
> 
>         parsed_entry = parsed.setdefault(ifindex, {"rx":[], "tx": []})
>         parsed_entry[entry["queue-type"]].append(entry['queue-id'])
> 
> Sometimes this can be used to inline the whole expression, such as
> mydict.setdefault(key, []).append(value), but that would be unwieldy here.

Ack, I used setdefault() initially but it made the line too
incomprehensible. Too many things get indexed at once..




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux