Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cpython_near_wasm_opt-0.8.11-py3-none-win_amd64.whl (13.1 MB view details)

Uploaded Python 3Windows x86-64

cpython_near_wasm_opt-0.8.11-py3-none-macosx_11_0_arm64.whl (7.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

cpython_near_wasm_opt-0.8.11-py3-none-macosx_10_9_x86_64.whl (9.0 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file cpython_near_wasm_opt-0.8.11-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.11-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b1b7b6ba49f2b901b8af3684cafc06c4036f95ca16e90942ec093cefcf4153e1
MD5 78512faa970d7c319c3652292fa6eb79
BLAKE2b-256 41cff0d19d7bfd64c23ed67628052b803927c00ef70aa72b2f5aeaa4ba874359

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.11-py3-none-win_amd64.whl:

Publisher: build.yml on past-hypothesis/cpython-near-wasm-opt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpython_near_wasm_opt-0.8.11-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.11-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3889e7aa951985c6194fffa83592e06eb1a001000aca1d38f56653b51270ea96
MD5 52c1d2f194df3035f2f47ba97a9130f5
BLAKE2b-256 5d1e77daa777843404d8211f48d1a8faaf0827978ff5562ea1f7a73e28e62599

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.11-py3-none-manylinux1_x86_64.whl:

Publisher: build.yml on past-hypothesis/cpython-near-wasm-opt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpython_near_wasm_opt-0.8.11-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.11-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ef3b4ffadf7e8feedb04be6a54ba7da27ba68ef66e98264e9ad2a100791075f7
MD5 25a587779a6aacb667235c26b21cd21c
BLAKE2b-256 a77a11f6a89ff4c367d08dd365729f19b44208d64434fbff32e00885857fe2ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.11-py3-none-macosx_11_0_arm64.whl:

Publisher: build.yml on past-hypothesis/cpython-near-wasm-opt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cpython_near_wasm_opt-0.8.11-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cpython_near_wasm_opt-0.8.11-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 47afca7df7c4eab6e823037fdedcb7aba810368e95d468a96c62a5829a96afc7
MD5 f0dd07203d15c4d9883dbfe5d98abd7a
BLAKE2b-256 65cb25c7cdc8386b6001cdaa6d658dc8399b7a343118be7d9645679f262662f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpython_near_wasm_opt-0.8.11-py3-none-macosx_10_9_x86_64.whl:

Publisher: build.yml on past-hypothesis/cpython-near-wasm-opt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page