(original) (raw)

RE: \[Python-Dev\] Re: Decimal data type issues

\[Kevin Jacobs\]

#- Thus, I would
#- like to create decimal instances that conform to those
#- schema -- i.e., they
#- would be rounded appropriately and overflow errors generated if they
#- exceeded either the maximum precision or scale.  e.g.:
#-
#-   Decimal('20000.001', precision=4, scale=0) === Decimal('20000')
#-   Decimal('20000.001', precision=4, scale=0) raises an
#- overflow exception
#-   Decimal('20000.001', precision=5, scale=3) raises an
#- overflow exception
#-   Decimal('200.001', precision=6, scale=3) === Decimal('200.001')
#-   Decimal('200.000', precision=6, scale=3) === Decimal('200') or
#- Decimal('200.000')
#-      (depending on if precision and scale are interpreted as
#- absolutes or
#-       maximums)
#-
#- In order to be able to accomplish this behavior in an
#- "external" library,
#- either the literals would have to be pre-parsed and manipulated, OR
#- an intermediate Decimal value would be created using the raw literal,
#- which would then used to detect overflows and then apply the
#- necessary rounding criteria based on the desired (maximum) scale.

I think that is better to include this functionality outside Decimal, by using it or inheritating it (the same way I'll include all money specific uses in other class).  Remember that Decimal is a module to implement the Arithmetic behaviour of decimal floating point.

All other specific use cases should be outside it.


#- Hopefully this is somewhat clearer.

Very, thank you.


#- Neither.  It is well understood that operations on Decimal instances
#- must rely on the
#- context.  The idea here is to overflow and round correctly
#- upon instance
#- creation without
#- going through a great deal of additional effort.

Don't know how much effort it will be. But I prefer that before bloating Decimal.

In the PEP I said:  "It is not the purpose of this PEP to have a data type that can be used as Money without further effort". This is applicable to other specific uses.

.       Facundo






. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

ADVERTENCIA 

La informaci�n contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener informaci�n confidencial o propietaria, cuya divulgaci�n es sancionada por la ley.

Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no est� autorizado a divulgar, copiar, distribuir o retener informaci�n (o parte de ella) contenida en este mensaje. Por favor notif�quenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magn�tico) que pueda haber realizado del mismo.

Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telef�nica Comunicaciones Personales S.A. o alguna empresa asociada.

Los mensajes electr�nicos pueden ser alterados, motivo por el cual Telef�nica Comunicaciones Personales S.A. no aceptar� ninguna obligaci�n cualquiera sea el resultante de este mensaje.

Muchas Gracias.