[Bob Ippolito] #- >>> hash(float(1.0)) == hash(1) == hash(1L) #- True #- #- Since this is already true, hash(Decimal.from_float(1.0)), #- hash(Decimal(1)), hash(Decimal(1L)), hash(Decimal('1.0')), #- hash(Decimal('1')), hash(Decimal(u'1.0')), etc. better be equal as #- well, whatever that takes. #- #- As far as arbitrary floats hashing equally, I don't really care, but #- the simple ones definitely should. Hopefully at some point, "float #- constants" (as in coming from source code or user input) in #- Python will #- actually be Decimal representations, so you don't lose #- precision until #- you ask for it. I agree. The detail is that the "simple ones" means the same Decimal that the ones constructed from ints: >>> Decimal.from_float(1.0) Decimal( (0, (1,), 0L) ) >>> Decimal(1) Decimal( (0, (1,), 0) ) >>> hash(Decimal.Decimal(1)) 1 So, you'll *always* have the same hash there. Regarding user input, treating them as strings, >>> Decimal('1') Decimal( (0, (1,), 0) ) >>> hash('1') 1977051568 There, you won't have the same hash that the string. But I don't think we need this as long as you can not compare Decimal with strings... . 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. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20040413/1acbb44d/attachment.html
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4