pypi / linehaul

ARCHIVED, replaced by https://github.com/pypa/linehaul-cloud-function/
https://github.com/pypa/linehaul-cloud-function/
Apache License 2.0
70 stars 38 forks source link

Attempt to optimize ParserSet #42

Closed dstufft closed 6 years ago

dstufft commented 6 years ago

The idea here is that because a ParserSet is short-circuiting, that it will stop iterating over parsers once it's found one that works, that we can optimize for the common case by putting the common cases before the uncommon cases in the search order.

We could do this manually, but that requires periodically validating that our order still matches reality. Instead this pull request will have the ParserSet periodically optimize itself by recording how many times each case was successfully used, and reorder the cases by how many times each one has been used.