That was quite a writeup - it's been a while since I've seen a time complexity analysis like this :-) But my comment still stands. Would you prefer like this?

https://github.com/pydata/pandas/pull/4140#discussion_r6806043