Skip to content

New layout for Arguments node to enhance performance. (and more so if possible) #57

@youknowone

Description

@youknowone

Currently the rust AST nodes layout is almost same as Python ast defined in Python side.

pub struct Arguments<R = TextRange> {
    pub range: OptionalRange<R>,
    pub posonlyargs: Vec<Arg<R>>,
    pub args: Vec<Arg<R>>,
    pub vararg: Option<Box<Arg<R>>>,
    pub kwonlyargs: Vec<Arg<R>>,
    pub kw_defaults: Vec<Expr<R>>,
    pub kwarg: Option<Box<Arg<R>>>,
    pub defaults: Vec<Expr<R>>,
}

Which is less parser-friendly than:

pub struct Arguments<R = TextRange> {
    range: ...,
    posonlyargs: Vec<Argument>,
    args: Vec<Argument>,
    vararg: Option<Box<Argument>>,
    kwonlyargs: Vec<Argument>,
    kwarg: Option<Box<Argument>>,
    type_comment: Option<String>,  // unparsed type_comment
    // no defaults and kw_defaults here
}

struct Argument {
    arg: Identifier,
    annotation: Option<Expr>,
    default: Option<Expr>,   // default is placed here unlike Arg
}

cc @MichaReiser

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions