4 ms·
Writing a simple Python to C compiler: hello, fibonacci
- aldanor 6y agoA good example of something similar that's actually very useful is Numba which is a Python-to-LLVM JIT compiler; extremely useful for writing fast numeric algorithms without leaving Python-land, sort of.
- tkuraku 6y agoNumba I think is the perfect tool for numeric code. Much easier to work with than Cython or native modules. You can also use numba to write Cuda functions.
- entelechy0 6y agoNever heard of Cython?
- giancarlostoro 6y agoFirst I was going to mention that this is what I believe Nim does (and Nim is closely similar to Python with its own differences), but I also forgot about Cython which achieves this as well. I guess the purpose of this though is to walk through the process which is more interesting than just being linked to Nim or Cython.
- deleted 6y ago[deleted]
- zwegner 6y agoThis is similar to Nuitka in that it generates code that binds with the Python C API, so it's easy to get compatibility/interoperability. I have an old, abandoned project that translates Python to C++ "from scratch", with no runtime dependencies beyond the STL[0]. It's very incomplete, and probably has plenty of bugs, but might be interesting for anybody looking for something more self-contained/embeddable. It has its own implementations of lists, dicts, etc., and a basic garbage collector. [0] https://github.com/zwegner/pythonc https://github.com/zwegner/pythonc