swaroopch / edn_format

EDN reader and writer implementation in Python, using PLY (lex, yacc)
https://swaroopch.com/2012/12/24/edn-format-python/
Other
131 stars 31 forks source link

Use mutable data structures to improve parsing time #52

Closed czan closed 5 years ago

czan commented 5 years ago

Previously a list was used to hold the intermediate results during parsing of "expressions", but each expression was prepended by copying, Fixing this takes parsing from quadratic to linear time.

This performance problem means that it takes some of our (very large) files over half an hour to be loaded in Python, against less than half a minute in Clojure.

swaroopch commented 5 years ago

Fixing this takes parsing from quadratic to linear time.

This performance problem means that it takes some of our (very large) files over half an hour to be loaded in Python, against less than half a minute in Clojure.

Wow! Thanks for looking into this @czan :)

@bfontaine Can you please review? Thanks!

bfontaine commented 5 years ago

Great idea! I added two remarks regarding avoidable calls to list(…) but otherwise :+1: