On Wed, Aug 26, 2020 at 11:57 AM Guido van Rossum <gu...@python.org> wrote:
> IIUC Cython (even if they were to adopt annotations) is not meant to be a > strict subset of Python -- almost no Cython module is valid Python. > correct. rather, it is a strict superset -- any valid Python should be compilable with Cython. But Cython type annotations are not valid Python. However, Cython has a "pure python" mode that IS valid Python: https://cython.readthedocs.io/en/latest/src/tutorial/pure.html It used to rely almost entirely on decorators and special function (e.g. cython.declare()) to add the Cython annotations -- these could simply do nothing when run through the Python interpreter. But apparently it now is using Type Hints as well. Or you can put the annotations in a separate file. But it does not support full Cython functionality. But if what you want is faster Python, it may well get you there. I hope the mypyc folks are at least keeping an eye on it -- the projects seem to have overlapping goals. In fact, when type hinting was standardized, it was explicitly said that >> that was not the goal. >> > > Right. And mypyc is experimental. But type hints *are* useful for > compilers (see also TorchScript). > Indeed. I suppose it's not the syntax that's the issue, but what types you use. If you use, e.g. Sequence, won't get much gain, but if you use a specific type, like List, then it can compile down to more efficient code. -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/FQY2QL4YNE6RVKFWA3QAHRRK7VZMJ3F2/ Code of Conduct: http://python.org/psf/codeofconduct/