Skip to content

1.0.1: global parser is re-created on every access (/ parse)

Latest
Compare
Choose a tag to compare
@masklinn masklinn released this 01 Feb 14:13

This led to the parser having to be re-created on every access, which is quite expensive for the re2 and regex-based parser and completely negates their purpose.

This can be worked around by using a from-import (as Python will do the memoizing in that case, although every such from-import would create its own parser still)

from ua_parser import parser

and only parsing through that parser (without using the top-level utilities), or by setting the global parser "by hand" e.g.

ua_parser.parser = ua_parser.parser 

but obviously that requires knowing about the issue.

Major thanks to @Rafiot for the report.