[Cython] PEP 492 implemented (async/await)
Hi, I invested a couple of days implementing PEP 492 in Cython. https://www.python.org/dev/peps/pep-0492/ It turned out nicely, so it's now merged into master to become part of Cython 0.23. I also spent some time testing and debugging it against Python 3.5 so that Yury Selivanov could adapt their side for interoperability. The second beta of 3.5 will be released tomorrow and it should "just work". Testing is very welcome. Note that the language feature is available in Cython for all Python versions (2.6+), but usage from Python code with async/await is obviously limited to Python 3.5 where this syntax is available. My guess is that one of the next asyncio (and trollius) backport package releases will add support as well, so that you could run Cython coroutines on top of asyncio also in older Python releases. It's mostly about dropping some explicit type checks here and there or replacing them with ABC isinstance checks. Have fun, Stefan ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Exporting inline functions from a pyx.
Jesus-Omar Ocegueda-Gonzalez schrieb am 27.05.2015 um 04:17: > we recently faced an issue exporting > inline functions defined in a .pyx. According to this: > http://docs.cython.org/src/tutorial/pxd_files.html > the full inline definition (not just the declaration) should be in the pxd. > However, if we put the definition in the .pyx and just its declaration > header in the .pxd, Cython declares a pointer to the inline function > similar to: > > static CYTHON_INLINE double (*__function_name)(...); /*proto*/ > > but this causes a compilation error in some platforms (but successfully > compiles in others) because variables cannot be declare as inline. Thanks for the report, I agree that this looks like a bug. I'm not entirely sure what the best fix is. We could make it an error if an external function declaration in a .pxd file is declared "inline", or we could just ignore the modifier for external functions on the import side. The first case would be more correct, but we'd end up with different declarations in the .pyx and .pxd files. That might be difficult to explain to users that run into this problem, as they would first have to understand that they can still declare their function "inline" in the .pyx file, just not in the .pxd. Just copying the function header over in order to export it will make your code fail to compile. But the second case might also not be without surprises ("why doesn't my 'inline' declaration work here?"), and it leaks implementation details into the .pxd. I'm thus leaning towards the first. I guess it just depends on coming up with a clear error message. (Well, after detecting this case in the first place...) Stefan ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Exporting inline functions from a pyx.
On Sat, May 30, 2015 at 10:46 PM, Stefan Behnel wrote: > Jesus-Omar Ocegueda-Gonzalez schrieb am 27.05.2015 um 04:17: >> we recently faced an issue exporting >> inline functions defined in a .pyx. According to this: >> http://docs.cython.org/src/tutorial/pxd_files.html >> the full inline definition (not just the declaration) should be in the pxd. >> However, if we put the definition in the .pyx and just its declaration >> header in the .pxd, Cython declares a pointer to the inline function >> similar to: >> >> static CYTHON_INLINE double (*__function_name)(...); /*proto*/ >> >> but this causes a compilation error in some platforms (but successfully >> compiles in others) because variables cannot be declare as inline. > > Thanks for the report, I agree that this looks like a bug. I'm not entirely > sure what the best fix is. We could make it an error if an external > function declaration in a .pxd file is declared "inline", or we could just > ignore the modifier for external functions on the import side. > > The first case would be more correct, but we'd end up with different > declarations in the .pyx and .pxd files. That might be difficult to explain > to users that run into this problem, as they would first have to understand > that they can still declare their function "inline" in the .pyx file, just > not in the .pxd. Just copying the function header over in order to export > it will make your code fail to compile. > > But the second case might also not be without surprises ("why doesn't my > 'inline' declaration work here?"), and it leaks implementation details into > the .pxd. I'm thus leaning towards the first. I guess it just depends on > coming up with a clear error message. (Well, after detecting this case in > the first place...) The first also has the disadvantage that one can't create an inline function that is exported as an imported function elsewhere... ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel