PERF: Only clear cached .levels when setting MultiIndex.names by mroeschke · Pull Request #59578 · pandas-dev/pandas (original) (raw)

When setting MutilIndex.names, all cached operations were invalidated. These names are only really tied to self.levels (which is also cached), but all usages of self.levels only requires the level values and not names, so we shouldn't need to invalidate operations which accessed the old self.levels values only.

Also removes a validate keyword in _set_names which was never set to False