Please read the new rule regarding the restriction on the use of AI tools. ×

darsh065's blog

By darsh065, history, 5 years ago, In English

I was solving a problem Secret Passwords from Round 603. When I submitted the solution 66044015 to the PyPy 3 compiler, it got TLE on test case 4 but the same solution 66043555 passes in Python 3. So why does PyPy 3 solution got TLE ?? Can anyone help me with this ?

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

PyPy is usually a lot faster, but not always.

This time I think that what you've experienced is that Python3 (Cpython3) has faster IO than PyPy3. I tried switching to a faster kind of input in PyPy3, and now it gets AC in 0.5 s. I could even speed up things further by avoiding to use unicode (python 3's default strings uses unicode) going down to 0.3 s. The later one is what I use when I don't want to bother with a template but need faster input.

Cpython3 also gets a small boost from the faster input, now taking 0.93 s.

I've competed on codeforces a lot with PyPy, but if codeforces didn't have PyPy I wouldn't even use python. For most problems you need the extra speed you get from using PyPy. I think using PyPy together with a template speeding up the IO is a pretty good combo if you want to code in python, but it is always going to be a struggle to compete against C++.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    How do I realise when to use pypy and when python3?