Open timotheecour opened 3 years ago
A more direct comparison would be with:
http://mongoc.org/libbson/current/index.html
The 'bson' implementation of decimal is the same fixed "bid" 128-bit IEEE 754-2008 standard.
The python version (which is mpdecimal) is a dynamic 32/64/128-bit of a variant of the same standard.
I'm confident both mpdecimal
and mongoc
are faster at the moment since I've not done any optimization.
(I have freely studied the algorithms from both to help write my library.)
Speaking of that; is there any movement to adding 128-bit integers to Nim?
GCC 4.1 and later support __int128_t
and __uint128_t
along with the relevant ops; at least on 64-bit platforms.
Using 128-bit uint math on the significand (the numbers part) for some of the ops would very likely improve speed quite a bit.
(EDIT)
Yeah, I kind of recall this now. If 128 bit support in a 64 bit architecture is detected, mpdecimal totally uses uint128 for the math.
performance
for https://github.com/nim-lang/Nim/pull/17699, we should have a performance comparison against established decimal128 libraries.
links
[WIP] Adding Decimal to Std library by JohnAD · Pull Request #17699 · nim-lang/Nim
mpdecimal — mpdecimal project libmpdec - C library libmpdec++ - C++ library
python3:
import decimal