pint icon indicating copy to clipboard operation
pint copied to clipboard

Save unit registry to file

Open tartieret opened this issue 8 years ago • 3 comments

As it is possible to load unit definitions from a file, would it be possible to add a "save_as_file" function? This would allow to create units dynamically and save them on disk for re-use later ?

tartieret avatar May 30 '17 20:05 tartieret

That is not possible but there was also an idea to support a user configurable unit definition list that is stored in the home directory and loaded automatically upon start. I do not know if there is really a demand for this.

hgrecco avatar May 30 '17 20:05 hgrecco

I'd be interesting in something like this to speed up loading all the unit definitions. Profiling on my system, just loading the definition takes about 700ms, mostly parsing/tokenzing, and then using the definitions to do a single unit version takes the other 50ms. I tried just pickling the UnitRegistry but no luck.

varenc avatar Feb 04 '22 03:02 varenc

I should be possible to create a cache file by pickling the internal dictionaries and load them if the definition files have not changed.

hgrecco avatar Feb 04 '22 15:02 hgrecco