Pypy a TLE saviour for python

Revision en3, by alive_ak4c, 2022-10-07 10:29:19

Recently I was solving this question in python. I had thought of a solution and I tried submitting it in python 3, although most of my solutions were accepted via python 3 interpreter. This problem held me by TLEs, a bunch of them.

I was so confused that I started breaking the logic in further if else's only to find that they don't help. I started to search for reasons on the internet and stumbled upon this article just by luck.

It is a TLE saviour. I skimmed through the article and submitted my code in pypy 3 instead of python 3 and to my surprise, it got Accepted. My amusement didn't end here. The execution time was very much comparable to the c++ code and almost 5 times faster than python 3.

So I am switching to this interpreter now. And if you too are getting TLEs it is would be worthy to try submitting your code with pypy 3.

Happy Coding!!!

Edit1:

Looks like pajenegod has a valid point here, this is not always true.

My apologies!!!

Edit 2:

Codeforces submission page also recommends using PyPy. Proof

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English alive_ak4c 2022-10-07 10:32:36 58 Tiny change: 'd3d29.png)' -> 'd3d29.png)\n\n**So, it's a recommendation rather than a guarantee.**'
en3 English alive_ak4c 2022-10-07 10:29:19 155 Tiny change: '**PyPy**. ![Proof](' -> '**PyPy**. So ![Proof]('
en2 English alive_ak4c 2022-10-05 21:16:27 184
en1 English alive_ak4c 2022-09-28 22:29:54 1059 Initial revision (published)