Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197800

get_used_memory

Path csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups comp.lang.python
Subject get_used_memory
Date Fri, 12 Jun 2026 03:46:43 -0000 (UTC)
Organization A noiseless patient Spider
Lines 16
Message-ID <110fvf3$1tqe3$1@dont-email.me> (permalink)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Fri, 12 Jun 2026 03:46:43 +0000 (UTC)
Injection-Info dont-email.me; logging-data="2025923"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0B5bXXBo7vMcu21EIE5JW"; posting-host="5a6b6d231e0e9be9f43427287d24d23b"
User-Agent Pan/0.165 (Kostiantynivka)
Cancel-Lock sha1:YQ6Jj6OEljsfpMTSPLyi62QRm/8= sha256:a00nN1ydRuCO4wXeWTmmuUISTcMNW1ncB2pRxhchNyI= sha1:q87pEqcdxNJNuzCCBnI4zpi5ntU=
Xref csiph.com comp.lang.python:197800

Show key headers only | View raw


So I looked at the example Gambas program at
<https://gambaswiki.org/wiki/doc/whatisgambas> and marvelled at its
unnecessary complexity (UUOC, even). It’s like PHP with variable
declarations!

Here’s my version: excluding header comments and blank lines and
shebang line, it’s about half the size.

info = dict \
  (
    (entry[0][:-1], int(entry[-2]))
    for line in open("/proc/meminfo", "rt")
    for entry in (tuple(s.strip() for s in line.split(" ")),)
    if entry[-2] != ""
  )
print("Used memory: %d Kb" % (info["MemTotal"] - info["MemFree"] - info["Buffers"] - info["Cached"] + info["SwapTotal"] - info["SwapFree"] - info["SwapCached"]))

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

get_used_memory Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-12 03:46 +0000
  Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-12 07:18 +0000
    Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-13 12:38 -0700
      Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-13 19:58 +0000
        Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-13 20:02 +0000
          Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-13 14:13 -0700
            Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-13 21:35 +0000
              Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-13 15:20 -0700
                Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-13 22:53 +0000
                Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-14 17:23 -0700
                Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-15 00:40 +0000
                Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-14 18:18 -0700
                Re: get_used_memory Jon Ribbens <jon+usenet@unequivocal.eu> - 2026-06-15 07:20 +0000
                Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-15 12:02 -0700
                Re: get_used_memory Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-14 01:10 +0000
      Re: get_used_memory Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-14 01:09 +0000
        Re: get_used_memory Paul Rubin <no.email@nospam.invalid> - 2026-06-14 01:28 -0700
          Re: get_used_memory Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-14 23:56 +0000

csiph-web