Difference in Running Time on Leet Code

40ms difference is way too low to take seriously. The python runtime takes about that long to fire up. Architectural changes LeetCode might have made to their testing suit, python interpreter, etc. are the most likely suspect for this performance disparity. After all, you submitted your solution today while the other solution was submitted a while ago.

I had the same issue with a Java solution. I implemented almost an identical solution to the one with the fastest runtime, and running the same code 3 times gave me 3 different runtime results: 88ms, 104ms, and 74ms. Even though the runtime difference isn't that significant, it made a big impact on my % compared to other online submissions. (from better than 23% of submissions at 104ms to better than 94% at 74ms). If you're focusing on where your solution stands compared to other submissions, I would take it with a grain of salt since it can greatly vary based on slight runtime variations.