Skip to content

docs: added pyo3-nest to the tools#6203

Open
ppmpreetham wants to merge 1 commit into
PyO3:mainfrom
ppmpreetham:patch-1
Open

docs: added pyo3-nest to the tools#6203
ppmpreetham wants to merge 1 commit into
PyO3:mainfrom
ppmpreetham:patch-1

Conversation

@ppmpreetham

Copy link
Copy Markdown

Added pyo3-nest to the tools.

Example

use pyo3::prelude::*;
use pyo3_nest::{submodule, add_classes, add_functions};

#[pyclass]
struct Router;

#[pyclass]
struct Route;

#[pyfunction]
fn hello() -> &'static str {
    "Hello from Rust!"
}

#[pymodule]
fn my_extension(m: &Bound<'_, PyModule>) -> PyResult<()> {
    // top level classes
    add_classes!(m, Router);

    // nested submodules
    submodule!(m, "routing", add_classes!(Router, Route));
    submodule!(m, "utils", add_functions!(hello));

    // classes + functions
    submodule!(m, "api.v1.responses", 
        add_classes!(JSONResponse, ErrorResponse) && 
        add_functions!(success_response, error_response)
    );

    Ok(())
}

In Python:

from my_extension import Router
from my_extension.routing import Route
from my_extension.api.v1.responses import JSONResponse, success_response

Before

let routing = PyModule::new(py, "routing")?;
routing.add_class::<Router>()?;
routing.add_class::<Route>()?;
m.add_submodule(&routing)?;

After

submodule!(m, "routing", add_classes!(Router, Route));

@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 23.26%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 139 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
into_u128_max 1.5 µs 2 µs -23.26%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ppmpreetham:patch-1 (662d623) with main (022f8ce)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant