Skip to content

Selective narrowing#611

Open
nielstron wants to merge 4 commits intodevfrom
codex/selective-narrowing-lowering
Open

Selective narrowing#611
nielstron wants to merge 4 commits intodevfrom
codex/selective-narrowing-lowering

Conversation

@nielstron
Copy link
Copy Markdown
Contributor

Sometimes code looks like this

if isinstance(a, int):
   a = a + 1
   b = a
else:
   a = b"hello"

In this case we previously internally mapped a from its PlutusData representation to a builtin representation at every operation in the if branch. Now, when computationally useful, we only do it once for the entire branch introducing a cast like this:

if isinstance(a, int):
   a_tmp: int = a
   a_tmp = a_tmp + 1
   b = a_tmp
   a: Union[int, bytes] = a_tmp
else:
   a = b"hello"

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 10, 2026

✅ Binary Size Check Passed

Binary Size Comparison Report
Loading baseline measurements...
Measuring current binary sizes and execution costs...
Measuring assert_sum...
  O0: 54450 bytes
    Evaluating test case: valid_sum
      CPU: 44,089,759 | MEM: 239,074
  O1: 3440 bytes
    Evaluating test case: valid_sum
      CPU: 19,353,759 | MEM: 84,474
  O2: 3438 bytes
    Evaluating test case: valid_sum
      CPU: 19,314,516 | MEM: 84,242
  O3: 1296 bytes
    Evaluating test case: valid_sum
      CPU: 17,506,516 | MEM: 72,942
Measuring liquidity_pool...
  O0: 151088 bytes
  O1: 47478 bytes
  O2: 47144 bytes
  O3: 18544 bytes
Measuring marketplace...
  O0: 123448 bytes
  O1: 26036 bytes
  O2: 25940 bytes
  O3: 4708 bytes
Measuring gift...
  O0: 56918 bytes
    Evaluating test case: valid_withdrawal
      CPU: 51,588,498 | MEM: 263,835
  O1: 5256 bytes
    Evaluating test case: valid_withdrawal
      CPU: 28,276,498 | MEM: 118,135
  O2: 5252 bytes
    Evaluating test case: valid_withdrawal
      CPU: 28,198,012 | MEM: 117,671
  O3: 1614 bytes
    Evaluating test case: valid_withdrawal
      CPU: 25,702,012 | MEM: 102,071
Measuring wrapped_token...
  O0: 64204 bytes
  O1: 9186 bytes
  O2: 8906 bytes
  O3: 3770 bytes
Measuring micropayments...
  O0: 87178 bytes
  O1: 19562 bytes
  O2: 19488 bytes
  O3: 6918 bytes

============================================================
BINARY SIZE AND EXECUTION COST COMPARISON REPORT
============================================================

Total size change compared to previous release: +0 bytes

✅ No significant changes detected
============================================================

No significant binary size changes were detected in this PR.


This report compares the binary sizes of compiled contracts against the baseline from the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant