netzob icon indicating copy to clipboard operation
netzob copied to clipboard

Hash generation for Symbol generates a lot of collisions

Open skleber opened this issue 7 years ago • 0 comments

The function for hash generation (__hash__()) of Symbol objects uses the name property as input. This leads to seemingly identical objects just if their name is the same, e. g. the default name "Symbol". Moreover this violates Python's assumption that an object never changes its hash within its lifetime (name is set-able).

This makes it impossible to use a Symbol as identifier, e. g. as a key in a dict or member of a set: The last inserted Symbol with a name identical to any of the existing ones in the data structure will be replaced.

skleber avatar Oct 18 '18 13:10 skleber