diff options
author | sterni <sternenseemann@systemli.org> | 2023-01-25T13·39+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-01-25T14·30+0000 |
commit | 8a8325fb9d2cfaf7c208db0f7d676dcab9c4eba0 (patch) | |
tree | e7f106b49e3f5ac073da9d67e8f77f34a24a7ff3 /tvix/eval/docs/known-optimisation-potential.md | |
parent | 669496f0ba4924b19c911220b9290aa45db9f89c (diff) |
docs(tvix/eval): builtins.add is not equivalent to + r/5758
While it is in the given example, i.e. for integer addition, to claim that they are equivalent is a bit misleading: builtins.add is less overloaded than +, i.e. builtins.add "foo" "bar" will fail whereas "foo" + "bar" performs string concatenation. Change-Id: Ib52d530d1ab289b367565b286f06a76dd518d4fb Reviewed-on: https://cl.tvl.fyi/c/depot/+/7929 Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
Diffstat (limited to '')
-rw-r--r-- | tvix/eval/docs/known-optimisation-potential.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tvix/eval/docs/known-optimisation-potential.md b/tvix/eval/docs/known-optimisation-potential.md index e3015fc44b8a..df13577de3ba 100644 --- a/tvix/eval/docs/known-optimisation-potential.md +++ b/tvix/eval/docs/known-optimisation-potential.md @@ -64,8 +64,8 @@ optimisations, but note the most important ones here. * Inline fully applied builtins with equivalent operators [medium] - Some `builtins` have equivalent operators, e.g. `builtins.add` - corresponds to the `+` operator, `builtins.hasAttr` to the `?` + Some `builtins` have equivalent operators, e.g. `builtins.sub` + corresponds to the `-` operator, `builtins.hasAttr` to the `?` operator etc. These operators additionally compile to a primitive VM opcode, so they should be just as cheap (if not cheaper) as a builtin application. @@ -73,7 +73,7 @@ optimisations, but note the most important ones here. In case the compiler encounters a fully applied builtin (i.e. no currying is occurring) and the `builtins` global is unshadowed, it could compile the equivalent operator bytecode instead: For - example, `builtins.add 20 22` would be compiled as `20 + 22`. + example, `builtins.sub 20 22` would be compiled as `20 - 22`. This would ensure that equivalent `builtins` can also benefit from special optimisations we may implement for certain operators (in the absence of currying). E.g. we could optimise access |