Mercurial > lbo > hg > pcombinators
changeset 50:4a86c41e42f1 draft
Add performance tip to README
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Thu, 23 May 2019 22:37:55 +0200 |
parents | 9f7c57e5ef26 |
children | f5cfdd80cfe7 |
files | README.md |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/README.md Thu May 23 22:37:38 2019 +0200 +++ b/README.md Thu May 23 22:37:55 2019 +0200 @@ -46,3 +46,13 @@ NOTE: pcombinators is super slow right now... it could likely benefit from tightening parsers and making fewer calls to sub-parsers. Production use isn't quite recommended :) + +## Performance tips + +* Cache parsers instead of reconstructing them (usually only slight impact) +* Push parsers upwards: `Skip(Whitespace()).then(A() | B() | C())` is a lot cheaper than +`Skip(Whitespace()).then(A()) | ...` because the need for backtracking is greatly reduced. + * Or remove all whitespace before starting to parse. This is saving A LOT of time. +* Write native parsers for frequently occurring strings. See `primitives.py` for a canonical and a + fast implementation of integer and float parsing. +