Speed up your Python modules using Nim
Anirudh (~icyphox) |
Description:
If this title looks familiar to you, it’s because there was a similar talk last year, titled “Speed up your Python modules using Rust”. This talk draws inspiration from it, and aims to introduce a new systems programming language — Nim.
We all love Python, but we have to agree that it _sucks_ when it comes to writing performant code. Sure, you could write your code in C/C++, or perhaps even Rust. You can even use Python's ctypes
module to interface with foreign functions defined in dynamic libs generated by C/C++ or Rust.
All of this comes at a cost: the need to write code in a low level language, or in the case of Rust, the need to learn new (and perhaps, a tad complex) syntax.
Enter Nim, a new fast and efficient systems programming language, that's compiled, statically typed and offers C-like speed. But the one feature that seals the deal — elegant and more importantly, _Pythonic_ syntax.
Don't believe me? Here's a snippet of Nim code:
Basic outline of the talk
- Speaker info
- What makes Python slow
- A quick intro to Nim
- [DEMO] Using the
nimpy
Nim module to port computationally intensive Python code over to Nim (i.e. calling Nim from within Python) - [DEMO] Alternatively, calling Python from within Nim
- [DEMO] Comparing performance between vanilla Python, C and Python + Nim
- More on Nim — its current status and its community
- Q/A
Who is this talk for?
- Python devs looking to improve perf in their existing codebase
- Anyone looking for a systems programming language with the simplicity of Python
Potential takeaways
- Moving "slow" Python code over to Nim
- Nim ⇔ Python interop
- In general, a new approach to improve performance in Python code
Prerequisites:
- Basic Python programming knowledge
- Some understanding of DLLs (Dynamic Linked Libraries)
Content URLs:
Blog post — Speeding up Python with Nim by Robert McDermott
GitHub repo with scripts showcasing Nim + Python interop
Speaker Info:
I’m Anirudh, a computer science major at SRM IST, Kattankulathur, Chennai. My primary interest is computer security, and more specifically — offensive security, digital forensics and threat intel. I’m also a security researcher/CTF player at Sector443, an infosec community at our University. I've worked closely with a lot of organizations to provide security solutions, and have conducted pentests on their infrastructure. Apart from security, I actively contribute to open source projects, my most favourite being the Nim programming language.