2 comments

  • dima-quant1 day ago
    nimic is a lightweight pure Python package that emulates Nim types and constructions, making it straightforward to transpile to Nim and compile AOT. Key principle: nimic code is valid Python that runs unmodified in CPython and also transpiles to equivalent Nim code.<p>Because nimic code is just standard Python with type hints and ctypes shims, it is a fully valid CPython script, so you can use the Python REPL during development, drop a breakpoint in the middle of a heavy algorithmic loop and inspect the variables natively.<p>Zero Lock-In: You don&#x27;t need a special runtime engine. If the Nim compiler is not available, your script still runs (albeit slower than standard Python due to some emulation overhead) on any machine with Python installed.<p>Seamless Distribution: You can use this to develop high-performance logic natively in Python, debug it with Python tooling, and then compile to a native executable or C-extension via Nim.<p>Why Nim? Its syntax maps well to Python, it is rather clear how to emulate its constructions in Python, and its performance is comparable to C (as it compiles to C). Port of the &quot;trace-of-radiance&quot; Nim project to nimic can be found in &quot;ndsl_raytracer&quot; in my GitHub repo (dima-quant). With the compiled executable the render time for a single 512x288 scene dropped from many hours in Python to just 10 minutes on a single M1 CPU core. The repo also includes nimic ppm to mp4 converter.<p>Similar projects: - Pyccel (<a href="https:&#x2F;&#x2F;github.com&#x2F;pyccel&#x2F;pyccel" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyccel&#x2F;pyccel</a>): Python extension language using accelerators - SPy (<a href="https:&#x2F;&#x2F;github.com&#x2F;spylang&#x2F;spy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;spylang&#x2F;spy</a>) is a variant of Python specifically designed to be statically compilable while retaining a lot of the &quot;useful&quot; dynamic parts of Python. - Codon (<a href="https:&#x2F;&#x2F;github.com&#x2F;exaloop&#x2F;codon" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;exaloop&#x2F;codon</a>) is a high-performance Python implementation that compiles to native machine code without any runtime overhead.<p>It is still work in progress, e.g. there is no JIT and multiprocessing support yet, but now I&#x27;m not sure what functionality would be best to implement next. Any suggestions?
    • IshKebab1 hour ago
      I would start with a human-written README and benchmarks?
  • actionfromafar56 minutes ago
    Similar idea as Shedskin which is a (large subset of) Python to C++ transpiler<p><a href="https:&#x2F;&#x2F;github.com&#x2F;shedskin&#x2F;shedskin" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;shedskin&#x2F;shedskin</a>
    • dima-quant27 minutes ago
      Good suggestion, now I recall I heard about this project before. Good to see it is in active development.