[ 
https://issues.apache.org/jira/browse/THRIFT-2621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14059937#comment-14059937
 ] 

Jens Geyer edited comment on THRIFT-2621 at 7/12/14 10:41 PM:
--------------------------------------------------------------

-1 
I'm not so sure if this is a good solution. 

If there are multiple members, the generated code adds the hashes. This 
approach has several weaknesses. Here are some Python-specific guidances about 
how to write a good hash function, what to take care of, and what to avoid:

[Python docs on __ hash 
__|https://docs.python.org/3/reference/datamodel.html#object.__hash__]
[How to write a good hash function (in 
Python)|http://stackoverflow.com/questions/4005318/how-to-implement-a-good-hash-function-in-python]

If anyone of the Python guys want to chime in, please do.


was (Author: jensg):
-1 
I'm not so sure if this is a good solution. 

If there are multiple members, the generated code adds the hashes. That's very 
likely to destroy the distribution of the resulting hash, because it tends to 
produce values at the upper end of the  scale. 

Here are some Python-specific guidances about how to write a good hash 
function, 
what to take care of, and what to avoid. 

https://docs.python.org/3/reference/datamodel.html#object.__hash__
http://stackoverflow.com/questions/4005318/how-to-implement-a-good-hash-function-in-python

If anyone of the Python guys want to chime in, please do.

> Add basic default hash code method to python
> --------------------------------------------
>
>                 Key: THRIFT-2621
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2621
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Python - Compiler
>            Reporter: Jens Geyer
>
> GitHub user kishorvpatil opened a pull request:
>     https://github.com/apache/thrift/pull/156
>     Add basic default hash code method to python, 
>     It doesn't work for maps/lists. This based off Nathan Matz's patch for 
> storm branch 6d4b008512cd9fcd5a6bb598d09f35eaf2dc7412
>     
>     
> You can merge this pull request into a Git repository by running:
>     $ git pull https://github.com/kishorvpatil/thrift thrift_patch
> Alternatively you can review and apply these changes as the patch at:
>     https://github.com/apache/thrift/pull/156.patch
> To close this pull request, make a commit to your master/trunk branch
> with (at least) the following in the commit message:
>     This closes #156
>     
> ----
> commit f22d578579ab6a78fd07a99a59c2d4af2bb8d3f5
> Author: Kishor Patil <kpa...@yahoo-inc.com>
> Date:   2014-07-10T20:44:41Z
>     Adding default hash function to python
> ----



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to