Python 3.0 new integer division

Mark Dickinson dickinsm at gmail.com
Wed Apr 9 15:35:55 EDT 2008


On Apr 8, 6:01 pm, Jonathan Gardner <jgard... at jonathangardner.net>
wrote:
> On Apr 8, 2:25 pm, Grzegorz S³odkowicz <jerg... at wp.pl> wrote:
>
>
>
> > Isn't Decimal a BCD implementation?
>
> Yep, you are right and I am wrong.http://www.python.org/dev/peps/pep-0327/#why-not-rational

Strictly speaking, BCD doesn't come into it:  the coefficient of a
Decimal instance is stored simply as a string of digits.  This is
pretty wasteful in terms of space:  1 byte per decimal digit
instead of the 4 bits per digit that BCD gives, but it's
convenient and fairly efficient.

An alternative representation that's gained popularity recently is
DPD (densely packed decimal), which packs 3 decimal digits into 10
bits in a clever way that allows reasonably efficient extraction
of any one of the 3 digits.  Decimal doesn't use this either. :)

Mark



More information about the Python-list mailing list