[Python-Dev] Re: Decimal data type issues (original) (raw)

Tim Peters tim.one at comcast.net
Thu Apr 22 19:20:22 EDT 2004


[Batista, Facundo]

You mean adding a method to the context, to create a Decimal using itself as context and not the one from the thread?

Yes. This isn't novel: all the operations are like that already. For example, Decimal.abs() is also available as Context.abs(decimal). The semantic difference is that the Decimal methods implicitly use the current thread's current context object, while the Context methods (trivially) use an explicitly specified context object.

If yes, what about c.createdecimal(number) ?

I think the name's kinda wordy. What else would a Decimal.Context object want to create, other than a Decimal.Decimal?

And with floats? c.createdecimalfromfloat(number)? Or the same method that before?

I'd be happy with

c.from_string(a_string)
c.from_int(an_int_or_long) # and works identically to
                           # c.from_string(str(an_int_or_long))
c.from_float(a_float)

I have no intention of creating Decimals from floats, so I didn't pay attention to those arguments (other than to silently agree that the issues involved are ugly enough that float->Decimal should have its own spelling -- if we have to have it at all).



More information about the Python-Dev mailing list