Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.python Subject: Re: get_used_memory Date: Mon, 15 Jun 2026 12:02:52 -0700 Organization: A noiseless patient Spider Lines: 22 Message-ID: <87pl1r62zn.fsf@nightsong.com> References: <110fvf3$1tqe3$1@dont-email.me> <8733yq9qov.fsf@nightsong.com> <878q8i87p7.fsf@nightsong.com> <874ij684ls.fsf@nightsong.com> <877bo07itf.fsf@nightsong.com> <87tsr461p9.fsf@nightsong.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 15 Jun 2026 19:02:53 +0000 (UTC) Injection-Info: dont-email.me; logging-data="617704"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hW3ngAyvCJNqX+WweecLF"; posting-host="70ba9729fdd7937c4d720e4250c15068" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cancel-Lock: sha1:Xv/M3T1/6/93qiS6QYR41RuI5sw= sha1:g4G6FM2xd7FtbJIIGbY/qEy38mM= sha256:GyRsh0QS5agFAtbgXC4Y96zuhmhiwNsPMIiTPG4FqXw= sha1:+BGhQ+Xt3KCveseylaBYSCBlR8c= Xref: csiph.com comp.lang.python:197818 Jon Ribbens writes: > My biggest complaint about := is the arbitrary and mysterious > restrictions on what you can use on the left hand side. You can't > even say "a.b := c". The PEP that introduced ":=" barely even > mentions these restrictions, let alone discusses or explains them. Yeah that's pretty annoying. Haskell doesn't have destructive assignments at all, but you can put the equivalent of match/case inside expressions. So, something like: fromList [(a, read b) | (a:b:_) <- words x | x <- xs] :: Map String Int The vertical bar is like "for" in Python's list comprehensions, "read" is like int(str) except it converts to arbitrary datatypes, "words" is like "split", and ":: Map String Int" is a type annotation that says it's making a dictionary mapping strings to Ints. The Int type signature tells "read" to convert to ints instead of floats or whatever. Finally, (a:b:_) binds the first two elements of x.split() and throws away the rest. I haven't tested the above so maybe I did something dumb. I haven't written any Haskell in a while.