|
|
|
|
|
by sumitgt
3541 days ago
|
|
I am new to the python ecosystem. I use python for solving problems and hackerrank and noticed that switching from python3 to pypy3 can mean the difference betwwen timing out on some problems v/s getting it to work. Can someone eli5 how pypy achieves such difference and why that improvement cannot be contributed back to python3? |
|
PyPy is a completely different implementation of Python, so it's impossible to simply contribute improvements from it to CPython. To answer the question I think you're asking, though, the main reason we can't just have PyPy replace CPython as the default implementation isn't strictly technical: The Python community (Guido in particular) has decided to keep the reference implementation (CPython) as simple and consistent as possible, so that it's easy to contribute to and doesn't have any surprising behavior. PyPy, by comparison, is an incredibly complex piece of software. Even if you ignore the fact that it would make contributions harder, its performance is, in many scenarios, actually significantly worse than CPython's, because its optimizations rely on specific patterns within your code. I think it's mostly a good thing that PyPy is its own project and not the default implementation of Python, because it allows Python (the language) to grow much faster than it would otherwise.
I hope that answers your question. I apologize to anyone who knows more about the details than I do if I over-simplified things. :)