(original) (raw)

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

\[Michael Chermside\]

#- > The issue is that this limit is artificial:
#-      \[...\]
#- > So, should we impose an artificial limit to the exponent?
#- >
#- > This is important, as there're several cases where this
#- > maximums are checked
#- > and exceptions raised and/or the numbers get changed.
#-
#- I strongly prefer for my programming language not to impose
#- aribtrary limits, however, I can't see myself using decimal
#- to represent numbers with 1 billion digits. So IMHO, I would
#- avoid the limit if possible, but if imposing the limit
#- permitted substantial code simplification or performance
#- improvements then I wouldn't complain. Much.

Actually, imposing the limit means more code and complexity, and I don't find any benefit.  But as I answered to Paul, I'm searching for community agreement before changing functionality that I found in the implementation


#- I disagree. If x == y, then that should imply that hash(x)
#- == hash(y).
#- So hash(Decimal(25)) == hash(25) had better be true. On the other
#- hand, hash(Decimal('-33')) CANNOT equal hash(Decimal('-33')), since
#- the latter must equal hash(-33). And I'm not particularly concerned
#- about floats... if it's easy to make the hashes equal for those few
#- numbers which can be expressed EXACTLY as both a (binary) float and
#- a (decimal) Decimal, then that's be "kinda nice", but since there
#- are so few values which can be expressed exactly as both a float
#- and a Decimal, I don't see it as a big issue.

So, while Decimal(25) == 25 is True, hash(Decimal(25)) should be equal to hash(25).

The detail is that you can NOT compare Decimal to floats or strings, so maybe we should not worry about them to give the same hashes.

I'm OK to make hash(int or long) == hash(Decimal(int or long)). But only to int or long, not float nor string.

Do you agree?

.       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.