That’s not what I understand from the code. If you look at the output of the notebook. Note that the same tokenizer is used in all cases and not reinitialised. So It is not “jus the first call to the tokenizer”.

tokenizing only once: 20.22ms
tokenizing ten times the same text: avg. 7.96ms
tokenizing 100 times: avg. 0.19ms

So yes, the first time in the loop is slow, but not the first time for the tokenizer because the tokenizer is not re-init. So it is not likely that a pyc is recreated every time a new loop is encountered.
I thought at first that perhaps the result was being cached by the tokenizer (~ lru cache) but even with random string generation at each iteration I see this behavior.