Re: get_used_memory

Jon Ribbens <[email protected]> Sat, 13 Jun 2026 22:53:48 -0000 (UTC)
Newsgroups comp.lang.python
Organization A noiseless patient Spider
Message-ID <[email protected]>
On 2026-06-13, Paul Rubin <[email protected]> wrote:
> Jon Ribbens <[email protected]> writes:
>> Lawrence's version used your neat dict(line.split()[:2] ...) trick.
>
> Maybe this:
>
>    dict((a,int(b)) for a,b in (x.split()[:2] for x in xs))
>
> I feel like there should be a way to do this with the := operator
> instead of the nested generators, but it doesn't seem to be there.

That was the way my version did it? If I use abbreviated variable names
like your version, it's actually shorter than yours ;-)

     {e[0][:-1]: int(e[1]) for x in xs if (e := x.split())}