[Python-Dev] C Decimal - is there any interest?

Mateusz Rukowicz mateusz.rukowicz at vp.pl
Tue Oct 16 17:24:30 CEST 2007


Mark Dickinson wrote:

>On 10/15/07, Mateusz Rukowicz <mateusz.rukowicz at vp.pl> wrote:
>  
>
>>[...] I
>>would like to know if there is still interest in C version of Decimal.
>>If so - should I write PEP, or just code and 'we'll see later'?
>>    
>>
>
>I'd be happy to see decimal.py replaced by a C version giving
>essentially the same functionality.  I think the current decimal would
>certainly benefit from a speedup: it's probably `fast enough' for many
>applications, but it suffers horribly at high precisions:  addition of
>two n-digit decimals takes time quadratic in n, for example.
>  
>
Well, I am pretty sure, that addition works in linear time in Python 
version :>.

Speaking of performance in high precision computation - a year ago that 
was my aim, to make high precision computation fast, but now I see it 
different way. That is - I am not really convinced, if ie. adding 2k+ 
lines just to make multiplying fast (some fft-like multiplication) is 
worth it - depends on how many people would like to perform computations 
with prec around 100k+ digits ;). So at the moment, pretty much 
everything will work in asymptotically the same time as in Python 
version, but will be faster by some constant (which is quite big 
anyway). It will make C version suitable for medium precision 
computation (let's say 1000-10k digits ;>) - of course, if there is 
demand for high speed high precision, I would love to implement that 
(that's what I wanted at the beginning), but in that case, project would 
really overgrow (it already is really big as for one C file ;).

All I am saying is I want to make situation with many low precision 
arithmetic operations works fast (just like my tiny and pretty useless 
benchmark ;P - but I was surprised by result ;>) - and because I write 
in C, it is not really hard ;).

PS I think, that Py and C version of Decimal may live together and 
cooperate ;>.
PSS Py Decimal uses Python multiplication, so this one is asymptotically 
better than mine.

Thanks for opinion :)


More information about the Python-Dev mailing list