MCPcopy Index your code
hub / github.com/python/cpython / prepare_wasm

Function prepare_wasm

Platforms/emscripten/prepare_external_wasm.py:23–36  ·  view source on GitHub ↗
(input_file, output_file, function_name)

Source from the content-addressed store, hash-verified

21
22
23def prepare_wasm(input_file, output_file, function_name):
24 # Read the compiled WASM as binary and convert to hex
25 wasm_bytes = Path(input_file).read_bytes()
26
27 hex_string = "".join(f"{byte:02x}" for byte in wasm_bytes)
28
29 # Generate JavaScript module
30 js_content = JS_TEMPLATE.format(
31 function_name=function_name, hex_string=hex_string
32 )
33 Path(output_file).write_text(js_content)
34
35 print(f"Successfully compiled {input_file} and generated {output_file}")
36 return 0
37
38
39def main():

Callers 1

mainFunction · 0.85

Calls 5

PathClass · 0.90
read_bytesMethod · 0.45
joinMethod · 0.45
formatMethod · 0.45
write_textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…