Get the latest tech news

Making CRC calculations in Mojo 18x faster than Python and 3x slower than Python


Or how I made CRC-32 calculations 18 times faster than Python, and 3 times slower than Python.

I found the Wikipedia article on Polynomial long division to be helpful, and if you want an in depth explanation then this post by Kareem Omar does an excellent job of explaining both the concept and implementation considerations. 1-byte tabularnum_tables = 12561 KB2-byte tabularnum_tables = 25122 KB4-byte tabularnum_tables = 410244 KB8-byte tabularnum_tables = 820488 KB16-byte tabularnum_tables = 16409616 KB32-byte tabularnum_tables = 32819232 KB64-byte tabularnum_tables = 641638464 KBIn Kareem Omar’s original post the recommendation is to not go above a 16-byte table, as this will take up approximately half of the standard 32 KB of L1 cache on most computers. Well, this lead me down a rabbit hole and I ended up reading a pretty informative whitepaper by Andrew Kadatch and Bob Jenkins titled Everything We Know About CRC But Afraid To Forget.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of python

python

Photo of CRC calculations

CRC calculations

Photo of Mojo 18x

Mojo 18x

Related news:

News photo

HPy – A better C API for Python

News photo

What Can a Coffee Machine Teach You About Python's Functions?

News photo

Python 3.13 Sees Last Minute Delay Due To Performance Regression