A drawback of using PyPy vs Python

Правка en1, от xordux, 2020-07-06 22:09:44

I always saw Python(CPython) as inferior to PyPy3, because of SPEED

but today while working on a easy problem(189A - Cut Ribbon) I found that I was getting repeated Runtime Errors. I tried to improve my code but my solution didn't got Accepted.

My (Runtime error) PyPy3 solution: https://mirror.codeforces.com/contest/189/submission/86150951

after struggling for sometime, I thought I should give Python(CPython3) a try and submitted the same code in Python3. Voila!! I got AC immediately.

My (Accepted) Python3 solution: https://mirror.codeforces.com/contest/189/submission/86150968

What was I doing wrong? I don't know clearly for now, but I can see that there is a huge difference in memory consumption of Python3(8952 KB) and PyPy3(24604 KB). Maybe my solution was taking too much memory in PyPy3 and that's why it got Runtime error.

I googled about it for few minutes and found a wonderful article explaining why PyPy3 consumes lot of memory: https://morepypy.blogspot.com/2013/10/incremental-garbage-collector-in-pypy.html

This article basically says: The main reason why PyPy is faster than CPython is that PyPy delays garbage collection. Please correct me if I am wrong.

TLDR; Use Python when you are getting error with PyPy

Теги #pypy3, #python, #python3

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский xordux 2020-07-06 22:13:07 129 Initial revision
en1 Английский xordux 2020-07-06 22:09:44 1427 Initial revision (published)