Closed uri-p closed 1 year ago
Hi @uri-p - thank you for reporting this issue.
Please check this branch - https://github.com/konradhalas/dacite/tree/feature/performance-improvements - it has many performance improvements (eg. cache for get_type_hints
and many others calls - check this commit - https://github.com/konradhalas/dacite/commit/7e1a9227c7bd0084aa198d925dfafca04b10efe0). I hope that I will merge it soon, but it still needs some adjustments.
Thank you for the quick answer, I checked your branch and it looks exactly like some of the improvements I wanted to add. I use dacite heavily and those improvements are super important.
Hope you will push it soon :-)
Cool :) Please notice that you can share Cache
object between multiple from_dict
calls, so it's nice performance improvement if you want to build many objects of a single dataclass.
Very useful !
Are there any news regarding this? :)
Any news? "share Cache object between multiple from_dict calls, so it's nice performance improvement if you want to build many objects of a single dataclass." This would be great!
@mciszczon introduced cache
feature via https://github.com/konradhalas/dacite/commit/3c0e180a1e5295ca4b2eb023b492796939f18bf5
Calling get_type_hints consume a lot of CPU time. When calling the from_dict multiple times with the same Class type this optimization can save around 50% of the runtime.
Suggestion for the change:
` @lru_cache(maxsize=100) def _get_type_hint_with_cache(_data_class): return get_type_hints(_data_class, None)
`