I'm guessing I'm doing something wrong, because it makes very little sense when reading the doc but in short, on my machine, the slowest parser is ua-parser-rs.
That's what I'm doing in ipython (but I have the same results just with the python interpreter, it's just easier to time it):
from ua_parser import parse
ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
%timeit parse(ua_string).with_defaults()
734 ms ± 27.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
188 ms ± 10.9 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
- After I uninstall
ua-parser-rs and google-re2
1.07 ms ± 33.3 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
I'm on ubuntu 24.10 with Python 3.12.7.
Do you have any idea what's going on there? Something related to the cache being reloaded on every call? I couldn't find a way to avoid that.
I'm guessing I'm doing something wrong, because it makes very little sense when reading the doc but in short, on my machine, the slowest parser is
ua-parser-rs.That's what I'm doing in ipython (but I have the same results just with the python interpreter, it's just easier to time it):
ua-parser-rs:734 ms ± 27.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)google-re2188 ms ± 10.9 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)ua-parser-rsandgoogle-re21.07 ms ± 33.3 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)I'm on ubuntu 24.10 with Python 3.12.7.
Do you have any idea what's going on there? Something related to the cache being reloaded on every call? I couldn't find a way to avoid that.