Python str id hash -
i'm trying convert user access log pure binary format, require me convert string int using hash method, , mapping relationship of "id -> string value" stored somewhere further backward retrieve.
since i'm using python, in order save process time, instead of introducing hashlib calculate hash, can use
string_hash = id(intern(some_string))
as hash method? basic difference aware of comparing md5 / sha1? probability of conflict higher md5 / sha1?
doesn't work. id
not guaranteed consistent across interpreter executions; in cpython, it's memory location of object. if consistent, doesn't have enough bytes collision resistance. why not keep using strings? ascii or unicode, strings can serialized easily.
Comments
Post a Comment