1. RustPython基于 Rust 的 Python 解釋器

        聯(lián)合創(chuàng)作 · 2023-10-02 00:53

        RustPython 是一個由 Rust 編寫的 Python 3 解釋器。RustPython 可以嵌入到 Rust 程序中,使用 Python 作為應用程序的腳本語言,也可以將其編譯為 WebAssembly,在瀏覽器中運行 Python。

        用法:

        RustPython 需要 Rust 1.43.0 或以上版本,可以使用以下命令檢查 Rust 的版本:

        rustc --version

        如果想更新至最新版可以使用以下命令:

        rustup update stable

        要在本地構建 RustPython,可執(zhí)行以下操作:

        $ git clone https://github.com/RustPython/RustPython
        $ cd RustPython
          # if you're on windows:
        $ powershell scripts\symlinks-to-hardlinks.ps1
          # --release is needed (at least on windows) to prevent stack overflow
        $ cargo run --release demo.py
        Hello, RustPython!
        

        或使用交互式 shell:

        $ cargo run --release
        Welcome to rustpython
        >>>>> 2+2
        4

        還可以使用以下命令安裝和運行 RustPython:

        $ cargo install rustpython
        $ rustpython
        Welcome to the magnificent Rust Python interpreter
        >>>>>
        

        或通過conda包管理器:

        $ conda install rustpython -c conda-forge
        $ rustpython
        

        WASI:

        可以使用以下命令將 RustPython 編譯為獨立的 WebAssembly WASI 模塊,以便可以在任何地方運行它。

        $ wapm install rustpython
        $ wapm run rustpython
        >>>>> 2 + 2
        4

        構建 WASI 文件

        使用以下方法構建 WebAssembly WASI 文件:

        cargo build --release --target wasm32-wasi --features="freeze-stdlib"
        瀏覽 38
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
          
          

            1. 一级肉片免费观看网站 | 嗯~啊~快点死我男男视频 | 91免费三级片网站 | 陈雅伦最猛的一部三级 | 啊啊啊慢点插 |