Purpose of this PR is to cache common lookups when they're unlikely to have been changed.
class ResourceIdentifier: This now is a frozen data class instead of inheriting from NamedTuple. This allows us to define the filename str representation on init and look it up when needed (used frequently in __hash__ and __str__. reminder that hashing any object happens in __eq__ calls and in collection objects like lists/dicts.
utility.system.path - str() representations cached. This used to be especially problematic for CaseAwarePath instances in pykotor.tools.path as any case-insensitive path instance would have get_case_sensitive_path on every call.
probably a few other places that could use @lru_cache for recursion-specific logic, much can be done still.
it seems most of this PR was unintentionally merged already during the fiasco of what was once bleeding-edge. I'll go ahead and merge this to complete the process.
Purpose of this PR is to cache common lookups when they're unlikely to have been changed.
class ResourceIdentifier
: This now is a frozen data class instead of inheriting fromNamedTuple
. This allows us to define the filename str representation on init and look it up when needed (used frequently in__hash__
and__str__
. reminder that hashing any object happens in__eq__
calls and in collection objects like lists/dicts.utility.system.path
- str() representations cached. This used to be especially problematic forCaseAwarePath
instances inpykotor.tools.path
as any case-insensitive path instance would have get_case_sensitive_path on every call.probably a few other places that could use
@lru_cache
for recursion-specific logic, much can be done still.