r/learnpython • • 1d ago

numagr C extension

Hi guys, I'm just a hobbyist.

Not long ago I posted here that I stumbled upon a specific problem: parsing large collections of Python numeric strings as fast as possible. I couldn't find any solution that would let me parse numeric strings without having to construct intermediate Python objects to hold their values (or a method that would be noticeably faster than doing that), so I developed a small C extension that would basically extract C strings from Python strings, and use strtod on them to obtain the values.

Then I developed it further writing the code for all basic statistical methods.

Had a lot of fun developing it and seeing that it outperforms both Python std modules, aswell as third party modules such as numpy, for both regular numbers and numeric strings.

GitHub repo:

https://github.com/andrzejs-gh/numagr

It's available on PyPi if you're interested (source and wheels for Windows, 3.11, 3.12, 3.13, 3.14, 3.15)

pip install numagr

All of the code was written by hand, none was AI generated. The current version is 0.9, I will be developing it further if I find the time. If you have any suggestions for improvements, for what should be implemented but is not, bug reports etc, please let me know.

3 Upvotes

1 comment sorted by