audeering / audobject

Generic Python interface for serializing objects to YAML
https://audeering.github.io/audobject/
Other
1 stars 0 forks source link

Speed up package name lookup in to_dict() #94

Closed hagenw closed 12 months ago

hagenw commented 1 year ago

Closes #90

This speeds up Object.to_dict() by calling importlib_metadata.packages_distributions() only ones and caches the results.

The benchmark shown in #90 is drastically faster now, as shown by the execution times:

function main this branch
measure_wo_serialization() 0.17 s 0.11 s
measure_w_serialization() 18.6 s 0.36 s
codecov[bot] commented 1 year ago

Codecov Report

Merging #94 (38d2591) into main (d1f3dd8) will not change coverage. The diff coverage is 100.0%.

Additional details and impacted files | [Files](https://app.codecov.io/gh/audeering/audobject/pull/94?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=audeering) | Coverage Δ | | |---|---|---| | [audobject/core/utils.py](https://app.codecov.io/gh/audeering/audobject/pull/94?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=audeering#diff-YXVkb2JqZWN0L2NvcmUvdXRpbHMucHk=) | `100.0% <100.0%> (ø)` | |