# Complexity Changes by Version

Every built-in function has a **complexity** cost, charged against a script's per-transaction complexity limit. Several built-ins get cheaper (rarely, more expensive) at a later standard library version, independent of any change to their arguments or return type — a script recompiled at a higher `STDLIB_VERSION` can pass where it previously failed the complexity limit, with no code change.

```{note}
Verified against node-scala v1.7.0. Generated by `docs/scripts/extract_ride_complexity.py` in this repository, run against a checkout of node-scala's `lang` module — see that script's docstring for exactly what it does and does not capture. Re-run it after every node-scala release to catch drift; a diff means this table needs updating.
```

Where a function has more than one row, each row is a distinct overload (different argument types) with its own cost curve — the extraction can't attach argument types to a row, only the version-to-cost map, so use the {doc}`function reference <03_functions>` to tell overloads apart by signature.

| Function | Complexity by version |
|---|---|
| `-` (BigInt unary minus) | V5=8, V6=8, V7=8, V8=1 |
| `createMerkleRoot` | V4=30, V9=3 |
| `drop` | V1=1, V4=6, V9=2 |
| `drop` | V1=1, V4=20, V9=2 |
| `dropRight` | V6=6, V9=2 |
| `dropRight` | V6=20, V9=2 |
| `fill` | V9=2 |
| `fraction` | V1=1, V5=14, V6=1 |
| `fraction` | V5=128, V6=1 |
| `getElement` | V1=2, V9=1 |
| `max` (list) | V5=192, V8=6 |
| `median` (BigInt list) | V5=160, V6=160, V7=160, V8=35 |
| `min` (list) | V5=192, V6=192, V7=192, V8=6 |
| `parseBigInt` | V5=65, V8=1 |
| `parseBigIntValue` | V5=65, V8=1 |
| `pow` | V3=100, V6=28 |
| `pow` | V5=200, V6=270 |
| `removeByIndex` | V4=7, V8=4, V9=1 |
| `replaceAll` | V9=2 |
| `replaceByIndex` | V8=4, V9=1 |
| `replaceFirst` | V9=2 |
| `size` | V1=2, V9=1 |
| `split` | V3=100, V4=75, V6=51 |
| `take` | V1=1, V4=6, V9=2 |
| `take` | V1=1, V4=20, V9=2 |
| `takeRight` | V6=6, V9=2 |
| `takeRight` | V6=20, V9=2 |
| `toBigInt` | V5=65, V8=1 |
| `toBytes` | V5=65, V8=1 |
| `toString` (BigInt) | V5=65, V6=1 |
| `toString` (Int/Boolean) | V3=10, V4=10, V5=10, V6=1 |

A missing version in a row means the cost from the previous listed version carries forward unchanged — e.g. `removeByIndex` stays at `4` for V8 until it drops to `1` at V9. `median` exists before V8: the `List[Int]` overload costs a flat `20` from V4 onward (so it has no row here), and the `List[BigInt]` overload costs `160` for V5–V7 and `35` from V8.

## Coverage

This table only includes functions whose cost is set directly with a string literal name — `NativeFunction("name", Map(...), ...)`. Some costs are set through a helper (for example the BigInt arithmetic operators `+`, `*`, `/`, `%`, all `V5 -> 8L`/`V5 -> 64L`, stepping to `1L` at V8, defined via a shared `bigIntArithmeticOp` helper) and aren't captured here, since attributing them correctly would mean guessing at the helper's argument order rather than reading it off a literal. Treat this page as a documented lower bound on what changed, not an exhaustive list — the {doc}`Standard Library Versions <08_stdlib-versions>` page covers every genuinely *new* function and structure field, which this page does not repeat.
