uvloop icon indicating copy to clipboard operation
uvloop copied to clipboard

Could uvloop be implemented using CFFI?

Open OOPMan opened this issue 8 years ago • 15 comments

Could uvloop be implemented using CFFI? How hard would it be to do so?

I ask because at some point in the future PyPy3 will reach compatibility with Python 3.5 (It could be a while, but PyPy3 3.3 is in alpha right now so there is hope :-) and it would be really great if uvloop were usable on it :-)

OOPMan avatar Jun 18 '16 08:06 OOPMan

Once PyPy implements Python 3.5 and is stable, we'll look into this. Theoretically, it's not that difficult to rewrite uvloop with pure Python + CFFI.

1st1 avatar Jun 21 '16 01:06 1st1

That's good to know. Thanks for answering my question!

OOPMan avatar Jun 21 '16 09:06 OOPMan

NP. Let's keep this issue open, as this question periodically comes up.

1st1 avatar Jun 21 '16 13:06 1st1

@1st1 by the way, you can already play around PyPy3.5, there's nightly builds: http://buildbot.pypy.org/nightly/py3.5/ It's not stable thought

Yardanico avatar Oct 17 '16 17:10 Yardanico

@1st1 the time has come! First public release of PyPy3.5

Yardanico avatar Mar 21 '17 11:03 Yardanico

I'll take a look soon :)

1st1 avatar Mar 21 '17 16:03 1st1

Referencing another discussion: https://github.com/MagicStack/uvloop/issues/82

1st1 avatar Mar 28 '17 21:03 1st1

https://github.com/saghul/pyuv already implements a CFFI extension that works on PyPy3 beta. It's just a matter of providing the necessary Python API that wraps it.

thedrow avatar Jun 11 '17 12:06 thedrow

@thedrow Where is CFFI in pyuv? I see no CFFI here, only usual Python C extension. If uvloop would use pyuv, PyPy3.5 would be slower, because Python C Extensions are slower than CFFI extensions (in PyPy). Uvloop wants to be fast, so if it wants to be fast on PyPy it should use CFFI

Yardanico avatar Jun 11 '17 12:06 Yardanico

@thedrow , @1st1, I found this uvloop CFFI extension - https://github.com/koehlma/uv/

Yardanico avatar Jun 11 '17 12:06 Yardanico

Seems like the CFFI extension is no longer maintained :(

thedrow avatar Oct 26 '17 12:10 thedrow

Maybe it is worth seeing what is necessary to make the existing Cython code work on PyPy. Cython supports cpyext for PyPy and PyPy has done some recent work to improve cpyext speed. Have people explored this path? If so, what are the known issues today?

jakirkham avatar May 01 '19 19:05 jakirkham

I'm writting an PyPy binding using CFFI for and webserver, and i really need an CFFI version, so i think i will start to write an CFFI extension for PyPy using uvloop as reference, is that ok? The project: https://github.com/cirospaciari/socketify.py

cirospaciari avatar Jun 01 '22 22:06 cirospaciari

@cirospaciari We're hoping Cython could emit HPy extension code in the future which will allow uvloop to run on multiple platforms easily.

thedrow avatar Jun 06 '22 14:06 thedrow

Related issue ( https://github.com/cython/cython/issues/4197 )

jakirkham avatar Jun 06 '22 17:06 jakirkham