PEP 327: Decimal Data Type

Stephen Horne steve at ninereeds.fsnet.co.uk
Fri Jan 30 11:03:55 EST 2004


On Fri, 30 Jan 2004 09:49:05 -0300, "Batista, Facundo"
<FBatista at uniFON.com.ar> wrote:

>I'll apreciate any feedback. Thank you all in advance.

My concern is that many people will use a decimal type just because it
is there, without any consideration of whether they actually need it.

95% of the time or more, all you need to do to represent money is to
use an integer and select appropriate units (pence rather than pounds,
cents rather than dollars, etc) so that the decimal point is just a
presentation issue when the value is printed/displayed but is never
needed in the internal representation.


That said, there are cases where a decimal type would be genuinely
useful. Given that, my only comment on the PEP is that a decimal
literal might be a good idea - identical to float literals but with a
'D' appended, for instance.

I wouldn't mention it now, seeing it as an issue for after the library
itself has matured and been proven, except for the issue of implicit
conversions. Having a decimal literal would add another class of
errors with implicit conversions - it would be very easy to forget the
'D' on the end of a literal, and to get an imprecise float implicitly
converted to decimal rather than the precise decimal literal that was
intended.

I don't know what the solution should be, but I do think it needs to
be considered.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk



More information about the Python-list mailing list