3 ms·
> My rather hasty prototype is actually implemented in Python - not a language you want to do tons of arithmetic in [...] It might actually not be too bad? Th
by eru 2y ago
> My rather hasty prototype is actually implemented in Python - not a language you want to do tons of arithmetic in [...]
It might actually not be too bad? The actual big integer arithmetic is written in some fast language, and Python is just the glue holding everything together.
- saagarjha 2y agoI don't think Python has a particularly optimized bignum implementation.
- nneonneo 2y agoAdditionally, it requires allocating memory for every operation. With a mutable bigint type, or fixed-size large integers (e.g. uint256) we could skip a lot of allocation overhead. I have previously prototyped big integer algorithms in Python, and when rewriting to Rust I have gotten massive speedups - there are just so many more opportunities to optimize in Rust/C/C++ than in Python.
- eru 2y agoWell, it's still better than trying to implement bignums in Python itself on top of limited precision integers. I'm not even sure whether the prototype in question here uses bignums. Perhaps they use numpy in some clever way (which would probably be a better illustration of my thesis). Or perhaps it's fast enough as it is?