10

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?

Artem Selivanov
  • 1,867
  • 1
  • 27
  • 45
  • Not really an answer, but maybe worth noting: [Trio](https://github.com/python-trio/trio) is a friendly asyncio alternative. There are [a number of differences](https://stackoverflow.com/questions/49482969/what-is-the-core-difference-between-asyncio-and-trio/49485603#49485603). Relevant here though: Trio fully supports pypy (e.g., every change is tested on pypy). – Nathaniel J. Smith Apr 17 '19 at 03:49

2 Answers2

26

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.

Manuel Jacob
  • 1,897
  • 10
  • 21
  • Apparently there's PyPy3.5 now? – Display Name Aug 18 '17 at 17:32
  • Well, PyPy3.5 is still not complete or production-ready. But in the last year our focus was mostly only on PyPy3.5, so I should update my answer. – Manuel Jacob Aug 18 '17 at 18:18
  • PyPy3.5 [doesn't seem to support](https://bitbucket.org/pypy/pypy/issues/2757/cant-import-asyncio-on-windows-importerror) asyncio until the native part of the module is reimplemented in Python. – user Apr 11 '18 at 11:49
  • @user PyPy3's Windows support (in general, not just for asyncio) is still in beta. I'll make it more clear in the answer. Thanks for pointing it out. – Manuel Jacob May 09 '18 at 15:33
0

No. According to PyPy website it is only Python 3.2.5 compliant, while asyncio requires Python 3.4 (actually can be installed using pip on 3.3, thanks @dirn). Also on Asyncio Wiki, it is stated that asyncio doesn't work on PyPy yet (though Wiki was last updated in August 2015).

romants
  • 3,660
  • 1
  • 21
  • 33
  • asyncio was added to the stdlib in 3.4, and can be installed through pip on 3.3. That doesn't affect the answer about PyPy, though. – dirn May 24 '16 at 16:59
  • 1
    this guy says otherwise http://stackoverflow.com/questions/8960747/stackless-in-pypy-and-pypy-greenlet-differences – Ale May 24 '16 at 17:26
  • maybe you should just try installing with pip asyncio – Ale May 24 '16 at 17:27
  • 1
    This answer is now incorrect due to the latest release of pypy3 5.5.0 Please consider editing the answer, or deleting. – Gary van der Merwe Oct 13 '16 at 13:33