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.
Metadata
Release files for cpython-near-wasm-opt 0.8.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| cpython_near_wasm_opt-0.8.13-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| cpython_near_wasm_opt-0.8.13-py3-none-manylinux1_x86_64.whl | Python 3 | none | Linux glibc 2.5+ x86-64 | Details |
| cpython_near_wasm_opt-0.8.13-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| cpython_near_wasm_opt-0.8.13-py3-none-macosx_10_9_x86_64.whl | Python 3 | none | macOS 10.9+ x86-64 | Details |
Total release size: 51.8 MB
Release files / cpython_near_wasm_opt-0.8.13-py3-none-win_amd64.whl
| Download URL | cpython_near_wasm_opt-0.8.13-py3-none-win_amd64.whl |
|---|---|
| Size | 13.1 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
93b3365ea6e77c8da1f299c0d29f7959bcb0c53f489c7e7ef342c557f926556a
|
|
BLAKE2b-256 checksum How to use checksums |
6d78a6a823eeb32c721b4a956d5c4dc5ef62ba8dc0f0cc94d33bf2b6a70f074d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 25, 2025.
Transparency logRelease files / cpython_near_wasm_opt-0.8.13-py3-none-manylinux1_x86_64.whl
| Download URL | cpython_near_wasm_opt-0.8.13-py3-none-manylinux1_x86_64.whl |
|---|---|
| Size | 21.8 MB |
| Tags | Linux glibc 2.5+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
4647345a11560dc0da230277b4fd5d01a3195770a621331c4c781df57df9b5c2
|
|
BLAKE2b-256 checksum How to use checksums |
959f2876fff474f2a4961838080ae14f06dfd46a3ff367209d2e4e569fc0f54c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 25, 2025.
Transparency logRelease files / cpython_near_wasm_opt-0.8.13-py3-none-macosx_11_0_arm64.whl
| Download URL | cpython_near_wasm_opt-0.8.13-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 7.9 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
04d9d49ef965b1ca25640c604f998fa5b13a2b10599776e017d631462038d5e8
|
|
BLAKE2b-256 checksum How to use checksums |
9cb185ea839030b289277528d1d78ab415ae5010d260176bed801eef110dd92e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 25, 2025.
Transparency logRelease files / cpython_near_wasm_opt-0.8.13-py3-none-macosx_10_9_x86_64.whl
| Download URL | cpython_near_wasm_opt-0.8.13-py3-none-macosx_10_9_x86_64.whl |
|---|---|
| Size | 9.0 MB |
| Tags | Python 3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
a5fcafbb281531d54a517370d80a7e2f840d5fe639b60dcec1557e258cb29179
|
|
BLAKE2b-256 checksum How to use checksums |
d5ea2b7cdaf345bcab1732a3b11436676ad693ae970bb89c9e34bd6633d48b6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 25, 2025.
Transparency log