compile Python code to WebAssembly for non-web environments

129 views Asked by At

I'm currently exploring if I can use a Python-based BACnet stack due to its reliability and effectiveness in conjunction with the possibility of leveraging Rust for its WebAssembly (WASM) capabilities, particularly in a non-web browser environment for IoT purposes as mentioned in this article for non-web embeddings. The main goal is to utilize Rust for specific tasks that benefit from WASM's performance, while maintaining the existing Python code for the BACnet stack. I think pyodide maybe only browser based WASM for Python and where using it for BACnet may not be feasible where BACnet is dependent on UDP communications where from my research maybe blocked by browsers for security purposes.

Approach Overview: Python BACnet Stack: Continue using the existing Python codebase for the BACnet stack.

Rust for WebAssembly: Utilize Rust for parts of the application that could benefit from WebAssembly's performance, such as data processing or interfacing with other systems.

Integration Strategy: Create a mechanism for Python and Rust to communicate effectively, potentially through a data exchange format like JSON or Protobuf.

Non-Web Browser WASM Environment: Adapt Rust components for compatibility with non-web WASM environments, understanding their specific APIs and limitations.

Challenges and Questions: Python in Non-Web WASM: Running Python in a non-web WASM environment is proving to be a challenge. Pyodide is primarily designed for web browsers, and I'm looking for tools or methods to compile Python code to WebAssembly that can work in non-web environments. Does anyone have experience or insights on accomplishing this?

Inter-language Communication: What are the best practices for data exchange between Python and Rust in this context? Any recommendations for efficient serialization and deserialization methods that work well with Python and WebAssembly?

Performance Considerations: Ensuring that the Rust-compiled WebAssembly modules are optimized for performance in a non-web environment. What are some key performance metrics to consider, and how can I benchmark these in a non-web WASM setting?

Thanks for any tips... not a lot of wisdom here but curious to explore more.

0

There are 0 answers