Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PyPy work with asyncio?

Does PyPy support the aio and Python 3.5?

I need the performance of PyPy and asynchrous code of asyncio. Also I need to use async/await in my code. Is that possible?

If so, what are the nuances?

like image 485
Artem Selivanov Avatar asked May 24 '16 16:05

Artem Selivanov


People also ask

What packages work with PyPy?

Compatibility: PyPy is highly compatible with existing python code. It supports cffi, cppyy, and can run popular python libraries like twisted, and django. It can also run NumPy, Scikit-learn and more via a c-extension compatibility layer.

What version of Python does PyPy support?

PyPy is a Python interpreter, a drop-in replacement for CPython 2.7, 3.7, 3.8 and 3.9. It's fast (PyPy and CPython 3.7. 4 performance comparison) due to its integrated tracing JIT compiler. We also welcome developers of other dynamic languages to see what RPython can do for them.

Does PyPy work with NumPy?

PyPy's developers have whittled away at this issue, and made PyPy more compatible with the majority of Python packages that depend on C extensions. Numpy, for instance, works very well with PyPy now. But if you want maximum compatibility with C extensions, use CPython.

Is PyPy same as Python?

Python and PyPy. The Python language specification is used in a number of implementations such as CPython (written in C), Jython (written in Java), IronPython (written for . NET), and PyPy (written in Python). CPython is the original implementation of Python and is by far the most popular and most maintained.


1 Answers

The current version of PyPy (version 7.2.0 at the time of writing) supports asyncio on at least Linux and Windows.


Old, now outdated (as of 2019-10-20) notes:

Currently there is a PyPy version (v7.0) compatible with Python 3.5 and a beta version (v7.1.1) compatible with Python 3.6. Both versions support asyncio on Linux (and probably macOS, but I didn’t try myself), but only the latter supports asyncio on Windows.


Old, now outdated (as of 2019-04-16) notes:

Currently PyPy supports Python 3.5, so asyncio should just work. However Python 3.x on Windows is still beta-quality. Unfortunately currently the extension module for overlapped IO, which is needed to run asyncio on Windows, isn't yet implemented.


Old, now outdated (as of 2018-06-10) notes:

Currently PyPy supports Python 3.5. Note that PyPy's Python 3 support is only beta quality in the moment. We are continuously working on improving it. It's not yet production-ready, though. Most code involving asyncio should just work. If not, please check the open bug reports or create a new one or let me know here in the comments.


Old, now outdated (as of 2017-08-18) notes:

Currently PyPy supports Python 3.3. This means that you can install asyncio on PyPy3.3. Note that PyPy's 3.3 support is only alpha / beta quality in the moment. We are however actively working on increasing performance and compatibility with CPython.

The async / await feature was added in Python 3.5. We started a very experimental branch with Python 3.5 support, but it's still got a long way to go. Luckily we have a GSoC student working on it currently, but still it could take several years (depending on how much donations and volunteer work we receive).

EDIT 1: Previously there was a feature missing to run asyncio. It was implemented shortly before this edit. The answer was edited accordingly.

EDIT 2: We just released an alpha version of PyPy3.3. We don't recommend anyone to try the old PyPy3 release supporting only Python 3.2. This is why I rewrote most of the answer.


Old, now obsolete (as of 2016-05-30) notes:

The PyPy3 version from the website is very old and only implements Python 3.2 - we haven't done a release for over one and a half year. Because Python 3.2 is missing the yield from feature, asyncio won't work with this version.

like image 161
Manuel Jacob Avatar answered Oct 23 '22 18:10

Manuel Jacob