This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients facundobatista, mark.dickinson, ncoghlan
Date 2009-01-10.17:42:46
SpamBayes Score 0.015502021
Marked as misclassified No
Message-id <1231609368.88.0.384621045482.issue2486@psf.upfronthosting.co.za>
In-reply-to
Content
(Adding Raymond to the nosy list.)

In r68494, I've checked in some work towards rewriting Decimal (or parts 
of Decimal) in C.  I reused Facundo's old /decimal directory in the 
sandbox, so the URL is:

http://svn.python.org/view/sandbox/trunk/decimal/decimal_in_c/

What's there is a fully functional hybrid Python and C implementation of 
decimal.  All the existing decimal tests pass, at least on my machine.  
There's very little performance increase to boast of at the moment, but 
that may change.  To try it, check out the directory and follow the
README instructions.  This probably doesn't work on Windows;  help
fixing that would be appreciated.

The code is for py3k only;  I started out maintaining versions
for both 2.x and 3.x, but that was just too painful.  I'd rather
get the py3k version working, then backport.

The main files are:
  deccoeff.c:  contains classes Deccoeff and _Decimal.  Deccoeff
    implements base 10 nonnegative integer arithmetic:  its instances
    can be treated as integers, but also sliced as though they were
    strings, which makes rounding and shifting operations simple.
    _Decimal is a minimal base class for Decimal;  the idea is
    to move functions from Decimal to _Decimal over time.
  decimal.py: version of Lib/decimal.py, fixed to use Deccoeff
    instead of string for the coefficient.

As I see it, there are two goals for this work:

(1) Speed decimal up.
(2) Bring proposals to add a decimal literal to C closer to realizability.

By the way, presumably it's not a prerequisite for (2) that *all* of the 
decimal.py functionality be recoded in C?  I could imagine a situation 
where the decimal literals are present in the core, but an 'import 
decimal' was necessary to get complete functionality.
History
Date User Action Args
2009-01-10 17:42:49mark.dickinsonsetrecipients: + mark.dickinson, facundobatista, ncoghlan
2009-01-10 17:42:48mark.dickinsonsetmessageid: <1231609368.88.0.384621045482.issue2486@psf.upfronthosting.co.za>
2009-01-10 17:42:48mark.dickinsonlinkissue2486 messages
2009-01-10 17:42:46mark.dickinsoncreate