# [Python-Dev] Decimal data type issues

Batista, Facundo FBatista at uniFON.com.ar
Tue Apr 13 16:04:02 EDT 2004

```[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

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

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20040413/855b22a6/attachment-0001.html
```