I’m currently trying to pin down a really weird performance regression between two commits in my code whereby a function that just does a basic dict read and insert is about 7x slower (0.122s vs 0.893s, both measured via cProfile) over the exact same set of inputs, on the exact same dict, with nothing that could really effect it changed.
I’m still trying to pin down the exact change that caused it, but I was initially curious, because I heard that python dicts have an inbuilt string fastpath method that is jettisoned for a generic implementation whenever a non-str access happens. (sorry if that is no longer the case, the info I found on it was quite old, I wasn’t able to find anything more up to date) The dict being used here is string keyed so I was curious if some weird interaction is causing the dict to lose the string fastpath and consequently slow down. Of course I have already inserted runtime checks to check for at every place the dict is read or written to and they didn’t raise any exceptions, but I’m running out of ideas.
So yeah, title, is it possible to inspect a dict object and see whether this substitution of fast str method for slow generic method has happened? How?
Thanks.