Hacker News new | ask | show | jobs
by fulafel 60 days ago
> What advantages does this provide beyond what can be achieved with Cython?

Turing completeness aside, it seems to have a different purpouse entirely.

Cython is Python-compatible with its own syntax extensions, and is meant for writing Python modules.

TurboPython is its own incompatible language that has some resemblance to Python and is presumably meant to be used independently of Python.

1 comments

Author here: you're right, it is a separate language that keeps Python's syntax (it uses Python's ast module for parsing) and as much of its semantics as possible. It does have extensions, but limited to new type annotations and decorators, for things like ownership or dynamic dispatch. It builds to a standalone native binary, but can also be used to compile CPython extension modules.

The source is valid Python though, with compiler warnings where the behavior diverges. In fact that's how it's tested: about 90% of the test cases are run through both TurboPython and CPython, and the output must be byte-identical. However, usually it doesn't work the other way around: not every Python program will pass TurboPython compilation, most will require adjustments to adhere to its stricter rules.

Example: https://github.com/trozen/tpy-lang/blob/master/tests/cases/a... (when run via CPython, the tpy package is a stub implementation of TurboPython's core types)