prePEP: Decimal data type

Batista, Facundo FBatista at uniFON.com.ar
Wed Nov 5 12:56:45 EST 2003


bokr at oz.net

#- so e.g.,
#-  Decimal('1.1')/Decimal('3') !(?)= Decimal('1.1000')/Decimal('3')

They are equal.


#- Or is the "Context" thing defining what all the "Decimal" 
#- constructions above do,
#- and extra zeroes in a literal may be ignored?

Why won't extra zeroes, at the right of the decimal, be ignored?


#- (If so, how does a "Decimal" know what "Context" to refer to 
#- if you have more than
#- one "Context" going? -- IOW why wouldn't you take 
#- Decimal+Context => Decimal subclass,
#- and let the sublass instance find its "Context" info by way 
#- of its inheritance instead
#- of some other Decimal<->Context association?

The Decimal has a context that dependes of its thread.

Each time it's about to do an operation, uses that context.


#- >Remember that the precision is in the context.
#- Sorry, how is context defined, so as to be accessed by the 
#- Decimal constructor?
#- Or is there a metaclass that modifies Decimal with custom context?

The context don't get attached to the decimal instance when it's built. The
context is something that "floats around" in each thread. And if that
instance is in that thread, that instance will use that context.


#- I guess I need a pointer to the context definition. I didn't 
#- wind up with a clear concept.
#- I probably was falling asleep or something. I guess I should 
#- re-read ;-/

No. I didn't explained it at all in the prePEP. It's all in the Cowlishaw's
work.

.	Facundo





More information about the Python-list mailing list