[Python-3000] [Python-Dev] Rounding Decimals

Raymond Hettinger python at rcn.com
Mon Jan 7 02:13:21 CET 2008


FWIW, I don't think all of these patches are helpful.  The implementations are so easy and the effects are so obvious, that it is 
simply better to decide what to do first, then do it afterwards.

My own preference is to leave the decimal module alone (except for a __round__ method to be called by builtin.round).  Adding more 
methods to that module does not make it easier to use -- there are already a mind-numbing range of choices in the current, minimal 
implementation of the spec.  I would support having a separate module of convenience functions or a separate module that uses a 
subset, but growth of the core module will only make it harder to use and more difficult to maintain.  Another idea for 
simplifcation is to write-up a good tutorial to the basics of using the module.

Please show restraint when proposing API changes to decimal -- I think it would be easy to do more harm than good.

Raymond




----- Original Message ----- 
From: "Jeffrey Yasskin" <jyasskin at gmail.com>
To: "Raymond Hettinger" <python at rcn.com>
Cc: "Mark Dickinson" <dickinsm at gmail.com>; "Python 3000" <python-3000 at python.org>; <python-dev at python.org>
Sent: Sunday, January 06, 2008 3:26 PM
Subject: Re: [Python-Dev] Rounding Decimals


> On Jan 6, 2008 1:21 AM, Jeffrey Yasskin <jyasskin at gmail.com> wrote:
>> On Jan 5, 2008 7:11 PM, Raymond Hettinger <python at rcn.com> wrote:
>> > > I think pep 3141's round(x, ndigits) does (1). The only thing it
>> > > doesn't support yet is specifying the rounding mode. Perhaps the pep
>> > > should say that round() passes any extra named arguments on to the
>> > > __round__() method so that users can specify a rounding mode for types
>> > > that support it?
>> >
>> > That would clutter the interface.  Just specify a universal rounding mode for __round__ and have Decimal's implementation of 
>> > that
>> > method comply.
>>
>> Yeah, thinking about this more, a .round() method on Context objects
>> seems like a better way to handle the part of Mark's request that the
>> round builtin doesn't cover. Of course, there may be even better
>> alternatives that I haven't thought of. I'll post a patch to
>> http://bugs.python.org/issue1623 tomorrow so we have something
>> concrete to talk about.
>
> The new patch is posted: http://bugs.python.org/file9080/decimal-3141.patch
> I'll implement Context.round() in a separate patch. Comment away. :)
>
> -- 
> Namasté,
> Jeffrey Yasskin
> 


More information about the Python-3000 mailing list