Re: get_used_memory
Jon Ribbens <[email protected]> Sat, 13 Jun 2026 20:02:55 -0000 (UTC)
| Newsgroups | comp.lang.python |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On 2026-06-13, Jon Ribbens <[email protected]> wrote: > On 2026-06-13, Paul Rubin <[email protected]> wrote: >> Jon Ribbens <[email protected]> writes: >>> with open('/proc/meminfo') as meminfo: >>> info = { >>> entry[0][:-1]: int(entry[1]) >>> for line in meminfo >>> if (entry := line.split()) >>> } >> >> with open('/proc/meminfo') as meminfo: >> info = dict(line.split()[:2] for line in meminfo) > > An excellent point, although it does mean the ':' characters remain > in the dictionary keys. Oh, and doesn't have ints as the dictionary values, which is rather more fatal to the use-case.