[issue19183] PEP 456 Secure and interchangeable hash algorithm

Serhiy Storchaka report at bugs.python.org
Mon Oct 28 18:15:37 CET 2013


Serhiy Storchaka added the comment:

> Because you can't simple replace the files.
  
Why not? This looks as simplest option when you build hard customized CPython.
 
>  It also contains _Py_HashBytes() and  _PyHash_Fini().
  
_PyHash_Fini() should be moved out too._Py_HashBytes() is only function which should be customized.
 
> I don't understand why you want me to get rid of the struct. What's your
 > argument against the struct? I like the PyHash_FuncDef because it groups
 > all information (func ptr, name, hash metadata) in a single structure.
  
Because it is redundant and only complicates the code, both use and declaration.
 
> > Why _Py_HashDouble() and _Py_HashPointer() are moved to pyhash.c? They are
 > > hash algorithm agnostic, and it is unlikely they will be redefined in
 > > custom build.
 > I have moved the functions to pyhash.c in order to keep all related
 > internal function in one file. They do not belong in Objects/object.c.
  
There are other hash related functions (hashing integers, tuples). Only _Py_HashBytes() should be customized and only it worth moving to separated file.
 
> > You not need the HAVE_ALIGNED_REQUIRED macros if use PY_UHASH_CPY (or
 > > something like for exact 64 bit) in siphash24. On platforms where aligned
 > > access is required you will use per-bytes copy, otherwise you will use
 > > fast 64-bit copy.
 > I'm not going to make siphash24 compatible with platforms that require
 > aligned memory for integers. It's an unnecessary complication and
 > slow-down for all common platforms. The feature will simply not be
 > available on archaic architectures.
  
The benefit is that the code will be simpler if get rid from HAVE_ALIGNED_REQUIRED and related code in ./configure. Only on such archaic architectures hash code will be slower.
 
> Serhiy, I would like to land my patch before beta 1 hits the fan. We can
 > always improve the code during beta. Right now I don't want to mess around
 > with SipHash24 code. That includes non-64bit platforms as well as
 > architectures that enforce aligned memory for integers.
  
Let first land simplified patch and then you could add features such as PY_HASH_EXTERNAL and PyHash_FuncDef.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19183>
_______________________________________


More information about the Python-bugs-list mailing list