python-sc2
python-sc2 copied to clipboard
Makes unit.tag be @cached_property
This commit is an optimization.
I ran cProfiler on an example bot of sorts and noticed that unit.tag is one of the worst offenders.
I made it a cached property instead and it cleared itself up.
This is due to heavy dictionary lookups in practice. Rasper has been manually caching tag in his framework for some time, using custom overrides and agrees this change is safe. So, nowhere in the library or in the wild do we manually change a unit's identifier once set.
I firmly believe this can go upstream.
Before:
After: