Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lawrence =?iso-8859-13?q?D=FFOliveiro?= 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> 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 So I looked at the example Gambas program at 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"]))