CPython-NEAR WASM optimizer tool
Project description
CPython-NEAR WASM optimizer tool
Allows packaging arbitray Python modules together with the contract source files into a self-contained WASM file ready for running on the NEAR blockchain.
Inputs: python.wasm -- pre-compiled CPython-NEAR WASM python-stdlib.zip -- pre-compiled CPython-NEAR stdlib .pyc files lib/ -- directory with contract source files and arbitrary Python modules to package into the WASM file
Optimizations: Optimizer runs the supplied contract with default arguments (or ones specified via @near.optimizer_inputs() decorator) and traces which Python modules and WASM functions get loaded/called during the runtime, removing unreferenced ones according to the optimization settings specified via -Ox, --module-tracing=1/0, --function-tracing=off/safe/aggressive cmdline arguments.
--function-tracing=safe (-O2 and lower) tries to only remove WASM functions which belong to non-referenced builtin Python modules, which is safer than --function-tracing=aggressive (-O3 and higher), which removes all unreferenced WASM functions except those pinned via DEFAULT_PINNED_FUNCTIONS or --pinned-functions=,,...
Optimized out WASM functions are replaced with a panic handler, which will, in case such a function has still been called during the contract runtime, print a message including the missing function name, which then can be added to the pinned function name list to ensure it is retained.
Additionally, LZ4 compression can be applied to WASM data initializer, which allows up to 500KiB WASM size reduction while consuming ~20Tgas for decompression.
Typical WASM sizes after optimization with json module included (-O4/3/2): 530/560/1363KiB.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cpython_near_wasm_opt-0.8.6-py3-none-win_amd64.whl.
File metadata
- Download URL: cpython_near_wasm_opt-0.8.6-py3-none-win_amd64.whl
- Upload date:
- Size: 13.0 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
892a5dd170b8f29b32e570bb2c58a3fb859a2a8b1f9954eefff16d66eef3f3aa
|
|
| MD5 |
fac6b8d6d2df18aca088ec2d2863f952
|
|
| BLAKE2b-256 |
a641375e3101bc907794f0f92aadaab6eabb59faa8c04760a10d49c309c8075f
|
Provenance
The following attestation bundles were made for cpython_near_wasm_opt-0.8.6-py3-none-win_amd64.whl:
Publisher:
build.yml on past-hypothesis/cpython-near-wasm-opt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpython_near_wasm_opt-0.8.6-py3-none-win_amd64.whl -
Subject digest:
892a5dd170b8f29b32e570bb2c58a3fb859a2a8b1f9954eefff16d66eef3f3aa - Sigstore transparency entry: 297711163
- Sigstore integration time:
-
Permalink:
past-hypothesis/cpython-near-wasm-opt@53741444fd7a3091bc32c560023952351af5bfaf -
Branch / Tag:
refs/tags/v0.8.6 - Owner: https://github.com/past-hypothesis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@53741444fd7a3091bc32c560023952351af5bfaf -
Trigger Event:
push
-
Statement type:
File details
Details for the file cpython_near_wasm_opt-0.8.6-py3-none-manylinux1_x86_64.whl.
File metadata
- Download URL: cpython_near_wasm_opt-0.8.6-py3-none-manylinux1_x86_64.whl
- Upload date:
- Size: 21.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
083c1ef6e2814e53cbace6990231d0d2b7de626d1fbea2bedca2d659e6a2c131
|
|
| MD5 |
c48fce94fa0055f89a727048df26a9b4
|
|
| BLAKE2b-256 |
8c6935b06d9aa3c68a38df813d519fbf92dfb056a712a3d3605bd3b7f8281c98
|
Provenance
The following attestation bundles were made for cpython_near_wasm_opt-0.8.6-py3-none-manylinux1_x86_64.whl:
Publisher:
build.yml on past-hypothesis/cpython-near-wasm-opt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpython_near_wasm_opt-0.8.6-py3-none-manylinux1_x86_64.whl -
Subject digest:
083c1ef6e2814e53cbace6990231d0d2b7de626d1fbea2bedca2d659e6a2c131 - Sigstore transparency entry: 297711201
- Sigstore integration time:
-
Permalink:
past-hypothesis/cpython-near-wasm-opt@53741444fd7a3091bc32c560023952351af5bfaf -
Branch / Tag:
refs/tags/v0.8.6 - Owner: https://github.com/past-hypothesis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@53741444fd7a3091bc32c560023952351af5bfaf -
Trigger Event:
push
-
Statement type:
File details
Details for the file cpython_near_wasm_opt-0.8.6-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: cpython_near_wasm_opt-0.8.6-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 7.8 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29b4c3ddd4f0bb0dcf5f1ba58987bac93fc4d7818b42e6f61d9f93d620f08bb9
|
|
| MD5 |
79f2721f7cb9332a26dc86123534b2e5
|
|
| BLAKE2b-256 |
7986659f69b8910cf02e917cc75262306b64ff1f27d026f426ace43fca0d059e
|
Provenance
The following attestation bundles were made for cpython_near_wasm_opt-0.8.6-py3-none-macosx_11_0_arm64.whl:
Publisher:
build.yml on past-hypothesis/cpython-near-wasm-opt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpython_near_wasm_opt-0.8.6-py3-none-macosx_11_0_arm64.whl -
Subject digest:
29b4c3ddd4f0bb0dcf5f1ba58987bac93fc4d7818b42e6f61d9f93d620f08bb9 - Sigstore transparency entry: 297711234
- Sigstore integration time:
-
Permalink:
past-hypothesis/cpython-near-wasm-opt@53741444fd7a3091bc32c560023952351af5bfaf -
Branch / Tag:
refs/tags/v0.8.6 - Owner: https://github.com/past-hypothesis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@53741444fd7a3091bc32c560023952351af5bfaf -
Trigger Event:
push
-
Statement type:
File details
Details for the file cpython_near_wasm_opt-0.8.6-py3-none-macosx_10_9_x86_64.whl.
File metadata
- Download URL: cpython_near_wasm_opt-0.8.6-py3-none-macosx_10_9_x86_64.whl
- Upload date:
- Size: 9.0 MB
- Tags: Python 3, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dec37eb449f2fcdf8f433b23f569004a32118d377e6be0d6e6fa211e1d0ef66
|
|
| MD5 |
0226ef1e61da60a4ad9ba1ac92fcbcbc
|
|
| BLAKE2b-256 |
3aeb5599c179606ac885756820fc525f7aea4f695c9325faf5a1c2421f277047
|
Provenance
The following attestation bundles were made for cpython_near_wasm_opt-0.8.6-py3-none-macosx_10_9_x86_64.whl:
Publisher:
build.yml on past-hypothesis/cpython-near-wasm-opt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cpython_near_wasm_opt-0.8.6-py3-none-macosx_10_9_x86_64.whl -
Subject digest:
2dec37eb449f2fcdf8f433b23f569004a32118d377e6be0d6e6fa211e1d0ef66 - Sigstore transparency entry: 297711132
- Sigstore integration time:
-
Permalink:
past-hypothesis/cpython-near-wasm-opt@53741444fd7a3091bc32c560023952351af5bfaf -
Branch / Tag:
refs/tags/v0.8.6 - Owner: https://github.com/past-hypothesis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@53741444fd7a3091bc32c560023952351af5bfaf -
Trigger Event:
push
-
Statement type: