!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1914 Members
Nix programming language355 Servers

Load older messages


SenderMessageTime
18 May 2026
@llakala:matrix.orgllakalafilterAttrs is heavier, requiring a whole removeAttrs15:53:23
@llakala:matrix.orgllakala

I personally choose not to use optionalAttrs in that way, instead choosing

  ${if cond then "foo" else null} = value;

xovidium has said that empty merges are free on new nix versions though

15:54:44
@llakala:matrix.orgllakala(I've been working close to the metal on mkDerivation, which makes me performance minded)15:55:17
@llakala:matrix.orgllakala * 15:57:12
@toonn:matrix.orgtoonn I have the same reservation about filterAttrs. The lambda also kinda obscures what's going on, it's too powerful in a way. 17:03:03
@toonn:matrix.orgtoonn Hadn't considered a dynamic attribute with if-then-else. Useful for multiple attributes at a time but I do feel like it's more obscure. 17:05:00
@chaotic.smol:matrix.orgArcadia (Cady) Rose joined the room.17:09:05
19 May 2026
@lumi:the-apothecary.clubNuwa changed their profile picture.14:56:39
@todoqki:matrix.orgtodo joined the room.15:41:02
@lumi:the-apothecary.clubNuwaRedacted or Malformed Event20:24:00
@amadaluzia:4d2.orgamadaluzia changed their profile picture.20:58:44
20 May 2026
@me:nahsi.devnahsi joined the room.09:09:48
@me:nahsi.devnahsi left the room.09:41:01
@me:nahsi.devnahsi joined the room.09:48:48
@lumi:the-apothecary.clubNuwa changed their profile picture.21:00:54
@lumi:the-apothecary.clubNuwa changed their display name from Hazel to Aspen.22:37:52
21 May 2026
@libregeekingkid:matrix.orgrajudev joined the room.00:00:20
@moatx:matrix.org@moatx:matrix.org removed their profile picture.15:47:26
@k.sommer:mozilla.org@k.sommer:mozilla.org joined the room.16:29:06
@k.sommer:mozilla.org@k.sommer:mozilla.org changed their display name from k-sommer to k-sommer 🏳️‍⚧️.16:29:51
@k.sommer:mozilla.org@k.sommer:mozilla.org changed their display name from k-sommer 🏳️‍⚧️ to 🏳️‍⚧️❄️ k-sommer (she/her).16:42:18
@bonsal2:matrix.orgjayf99 joined the room.18:45:33
@k.sommer:mozilla.org@k.sommer:mozilla.org left the room.20:48:28
@moatx:matrix.org@moatx:matrix.org left the room.22:01:44
22 May 2026
@lin_0kx:catgirl.cloud凛锋 changed their profile picture.10:24:09
@share-x:matrix.orgshare-x joined the room.15:22:09
23 May 2026
@exodus786:matrix.orgdj joined the room.06:04:20
@inclyc:matrix.orgYingchi Long changed their profile picture.11:24:37
@mtmn:matrix.orgmtmn joined the room.15:20:49
25 May 2026
@llakala:matrix.orgllakala

how does nix handle these differently when it comes to laziness?

let
  inherit (builtins) isInt genList;
  assertMsg = pred: msg: pred || throw msg;
  v1 =
    x:
    assert isInt x || throw "error message";
    x * 2;
  v2 =
    x:
    assert assertMsg (isInt x) "error message";
    x * 2;
  indices = genList (i: i) 100;
in
map v2 indices

i understand that assertMsg and similar functions (throwIf, warnIf, etc) are bad for performance - i can run stats on both versions and tell you that we go from 7 -> 107 thunks, 200 -> 400 function calls, and 4300 -> 7500 envs.bytes when using v2. what i don't get is how we're able to only have 7 thunks in the || case. how do we not need to create a thunk on every call?

01:58:00

Show newer messages


Back to Room ListRoom Version: 6