Skip to content

perf: JSON dict/list handler returns go through slow AttributeError + json.dumps path #217

Description

@ZhuchkaTriplesix

Where: src/dispatch.rs:1336-1402 (map_handler_return).

For the common case of a handler returning a dict/list, the current order is: try getattr("__oxyroute_stream_done__") (raises a real AttributeError on plain dicts — exception machinery on every JSON response), then several failed extract attempts, then get_item calls, then falls through to py.import("json").call_method1("dumps", ...).

Fix direction: check PyDict/PyList early (right after the str/bytes fast paths) and serialize directly in Rust by walking the Python object into a serde_json::Value/writer instead of round-tripping through json.dumps. This is likely the single biggest win for typical JSON-API workloads; also fixes the list-response correctness issue (#211).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions