nowfound

Dev tools · April 18, 2019

Inline Python – Rust macro to write Python directly in Rust source code

Inline Python code directly in your Rust code.

Inline Python – Rust macro to write Python directly in Rust source code launched on April 18, 2019 with 7 votes, #1,085 of 3,128 launches that month and more than 50% of that year's launches. The site was still online in September 2026, 7 years on.

What it does

Use the python!{..} macro to write Python code directly in your Rust code. To reference Rust variables, use 'var , as shown in the example above. var needs to implement pyo3::IntoPyObject . It is possible to create a Context object ahead of time and use it for running the Python code. The context can be re-used for multiple invocations to share global variables across macro calls. As a shortcut, you can assign a python!{} invocation directly to a variable of type Context to create a new context and run the Python code in it. A Context object could also be used to pass information back to Rust, as you can retrieve the global Python variables from the context through Context::get . Since the…from docs.rs

Does a similar job

all alternatives →
  • A Rust macro that parses Java-like syntax and runs it as a Rust program2018 · gitlab.com · ▲195

    A Rust macro that parses Java-like syntax and runs it as a Rust program

  • IC
    Inline C in Python2015 · quasiquotes.readthedocs.org · ▲14
  • Using Rust to write shell-script like tasks2020 · github.com · ▲231

    Common rust command-line macros and utilities, to write shell-script like tasks in a clean, natural and rusty way - rust-shell-script/rust_cmd_lib

  • PythonSandbox2022 · ▲157

    Write, run, debug, embed and share your Python code

  • PA
    Python at the Speed of Rust2025 · blog.fxn.ai · ▲68

    I’m sure many of you are familiar, but there’s a treacherous gap between finding (or building) a model that works in PyTorch, and getting that deployed into your application, especially in consumer-facing applications. I’ve been very interested in solving this problem with a great developer experience. Over time, I gradually realized that the highest-impact thing to have was a way to go from existing Python code to a self-contained native binary—in other words, a Python compiler. I was already pretty familiar with a successful attempt: when Apple introduced armv8 on the iPhone 5s, they…

  • WC
    Write code using natural language2019 · metacode.app · ▲209

More dev tools this month

the category →
  • /dev/null▲490

    a social network for devs

    Dev tools · 4d ago · dev-null.sh

  • open-source IDE for thoughtful software design. Contribute to devdotfast/whiteboard development by creating an account on GitHub.

    Dev tools · 29d ago · github.com

  • Contribute to reladraw/reladraw development by creating an account on GitHub.

    Dev tools · 27d ago · github.com

  • Contribute to oosexgang/hackios-xnu-kernel development by creating an account on GitHub.

    Dev tools · 15h ago · github.com

  • OpenBot▲362

    Grok Bot alternative: free, local, open-source, multiplayer

    Dev tools · 24d ago · openbot.run

  • Talanoa▲346

    Hi HN, I’m a fullstack developer, and honestly, I’ve lost count of how many side projects I’ve worked on over the years. But one idea kept coming back to me: a different kind of email client. It first came to me in 2014: “What if we could handle emails more like conversations?” Every year, I’d revisit this concept in my “Build Notes.” Ten years later, no one had built exactly what I had in mind — so I finally decided to do it myself. That’s how Talanoa was born. I wanted something focused on people, not timelines. I was tired of marking messages as unread just to remember to reply later, or…

    Dev tools · 21d ago · talanoa.email

Source: Show HN post ↗

Launched alongside, April 2019

the whole month →