Rcpp-like C++ inline in Python with cppFunction

If you used Rcpp back in the R days, this will feel familiar. I vibe-coded something over the weekend that does the same thing for Python: write C++ inline, call it like a normal function, get results back as numpy arrays. No build system, no separate files, no compilation step. ``` fn = cppFunction(''' std::vector<double> simulate(int n, double mu) { ... } ''') fn(10000, 2.5) ``` Projects like pybind11 and Cython are better for production C++ projects, but this is for when you just need one fast function right next to your Python code. The code compiles on the first call and is cached forever after. Armadillo works out of the box if you have it installed. https://lnkd.in/gt6YQENq

To view or add a comment, sign in

Explore content categories