[Python-Dev] Re: Decimal data type issues

Tim Peters tim.one at comcast.net
Wed Apr 21 21:24:58 EDT 2004


[Andrew P. Lentvorski, Jr.]
> Careful.  Omissions from technical specifications can be as important
> as inclusions.
>
> Why is there no round operation in the spec?  Is it that the
> functionality can be implemented using existing operations?

Yes.  In particular, what most people will want most of the time is exactly
supplied by the spec's quantize() operation (although that may not be
obvious at first).

> Is it that there is no good definition of the operation (I find this hard
> to believe)?

No.

> Does it have some strange side effect that causes problems?

No, although the many revisions quantize()'s definition has been thru bear
witness to how subtle it is to cover every endcase.

> I'm betting that the issue is that the performance of round() is
> dependent upon the chosen internal representation (ie. rounding a
> digit repesentation is O(1) but rounding a binary integer with scale
> could be O(n)).  Removing something which is in use but has this kind
> of subtle implication is far harder than adding a function later
> which got omitted.

Yes, although it's pretty easy to trust that nothing truly essential is
missing from the spec (lots of numeric experts have reviewed it, and that's
still in progress).

> For this pass, simply staying with the spec is more than sufficient
> work.

Indeed, it's a near crushing amount of work!

> Work which I heartily thank Facundo for doing.

Hear, hear!  (For non-English readers, that means "garbanzo magnifico
blotski!" <wink>.)




More information about the Python-Dev mailing list