make DateOffset immutable by jbrockmendel · Pull Request #21341 · pandas-dev/pandas (original) (raw)

Returning to the long-standing goal of making DateOffsets immutable (recall: DateOffset.__eq__ calls DateOffset._params which is very slow. _params can't be cached ATM because DateOffset is mutable`)

Earlier attempts in this direction tried to make the base class a cdef class, but that has run into pickle problems that I haven't been able to sort out so far. This PR goes the patch-__setattr__ route instead.

Note: this PR does not implement the caching that is the underlying goal.

I'm likely to make some other PRs in this area, will try to keep them orthogonal.