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


Groups > comp.lang.python > #197818

Re: get_used_memory

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: get_used_memory
Date 2026-06-15 12:02 -0700
Organization A noiseless patient Spider
Message-ID <87pl1r62zn.fsf@nightsong.com> (permalink)
References (8 earlier) <slrn112rnrs.5fs.jon+usenet@raven.unequivocal.eu> <877bo07itf.fsf@nightsong.com> <slrn112uifb.5fs.jon+usenet@raven.unequivocal.eu> <87tsr461p9.fsf@nightsong.com> <slrn112v9t5.5fs.jon+usenet@raven.unequivocal.eu>

Show all headers | View raw


Jon Ribbens <jon+usenet@unequivocal.eu> 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.

Back to comp.lang.python | Previous | Next — Previous in thread | 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