RustPython / Parser

MIT License
67 stars 24 forks source link

Reduce copying during parsing #60

Closed MichaReiser closed 1 year ago

MichaReiser commented 1 year ago

This removes the need for copying statements and other nodes during parsing.

Performance

This gives me a 4% performance improvement in ruff's parser benchmark (parses a couple of files and traverses the AST)

group                        main                                   stmt
-----                        ----                                   ----
parser/large/dataset.py      1.04      2.6±0.01ms    15.4 MB/sec    1.00      2.5±0.02ms    16.0 MB/sec
parser/numpy/ctypeslib.py    1.04    499.8±3.36µs    33.3 MB/sec    1.00    478.8±4.59µs    34.8 MB/sec
parser/numpy/globals.py      1.04     51.2±0.76µs    57.6 MB/sec    1.00     49.2±0.45µs    60.0 MB/sec
parser/pydantic/types.py     1.04  1100.1±11.99µs    23.2 MB/sec    1.00   1061.7±9.17µs    24.0 MB/sec