Re:The First 15 Years of PyPy – A Personal Retrospective
by uryga on Sunday September 09, 2018 @09:42PM
(#17948842)
I don't know about your question, but Cython recently added [1] the option to use native Python type annotations (Python 3.6, PEP 484) instead of its previous C-like dialect. That could lead to a situation where a sensibly type-annotated Cython file can still be a valid Python file – that would help with portability.
[1] https://github.com/cython/cython/issues/1672#issuecomment-33...
Re:The First 15 Years of PyPy – A Personal Retrospective
by acemarke on Monday September 10, 2018 @11:17AM
(#17952407)
Cython also supports writing type annotations in a separate .pxd file. It's a bit awkward because you're effectively duplicating all function + variable declarations, but it _is_ a valid way to keep the original Python source intact.
(On a side note, using this feature led to a particularly memorable debugging session that set a personal record in terms of time spent vs amount of code changed to fix the issue: https://news.ycombinator.com/item?id=11115110 ).
Re:The First 15 Years of PyPy – A Personal Retrospective
by maxerickson on Sunday September 09, 2018 @10:07PM
(#17948938)
There's a built in pattern that is at least similar to what you describe:
https://cython.readthedocs.io/en/latest/src/tutorial/pure.ht...
In the standard library, they maintain both Python and C versions of some modules:
That has always been my reason for not giving a Cython a real chance. I'm afraid I would go through the trouble porting everything, then have a use case where I need to just run pure python.
I've considered having a compat layer where you import dummy versions of all the classes and decorators if cython isn't present. Has anyone ever tried that?