rezemika / humanized_opening_hours

A parser for the opening_hours fields from OpenStreetMap
GNU Affero General Public License v3.0
26 stars 20 forks source link

Memoize get_parser #5

Closed erezsh closed 6 years ago

erezsh commented 6 years ago

Hi, you wrote in your readme:

you can save some time by passing the parser to the constructor, instead to recreate it each time. To do 
this, get the Lark parser with the humanized_opening_hours.field_parser.get_parser() function, and pass 
it to the OHParser constructor via the parser argument.

Perhaps a more user-friendly approach is to save the lark instance, either as a property in the OHParser instance like:

if not self._parser:
    self._parser = field_parser.get_parser()
return self._parser

Or as a global variable in the field_parser module.

Just a suggestion :)

rezemika commented 6 years ago

Hi! Thank you very much for your feedback!

I like the idea of a global variable, I'll do this. :)

rezemika commented 6 years ago

Sorry for the late, I was so busy lately. Done by 54123dd. Thank you! :)

erezsh commented 6 years ago

No problem, happy to help :)