Writing Python modules in Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. It’s Efficient, expressive, elegant and definitely worth to check. While I was playing with it, I stumbled upon an interesting module that allows almost seamless interoperability betweeen Nim and Python; so I’m building a small proof of concept on this github project. first of all the Nim code: # file: demo.nim - file name should match the module name you're going to import from python import nimpy import unicode proc greet(name: string): string {.exportpy.} = return "Hello, " & name & "!" proc count(names: seq[string]): int {.exportpy.} = return names.len proc lowercase(names: seq[string]): seq[string] {.exportpy.} = for n in names: result.add tolower(n) ...

December 5, 2020 · Andrea Manzini