More compact notation
This commit is contained in:
parent
a7bd65b904
commit
4b767a63ee
46
pep-0456.txt
46
pep-0456.txt
|
@ -180,9 +180,7 @@ finalize functions. Marek Majkowski C implementation csiphash [csiphash]_
|
|||
defines the prototype of the function. (Note: ``k`` is split up into two
|
||||
uint64_t)::
|
||||
|
||||
uint64_t siphash24(const void *src,
|
||||
unsigned long src_sz,
|
||||
const char k[16]);
|
||||
uint64_t siphash24(const void *src, unsigned long src_sz, const char k[16])
|
||||
|
||||
SipHash requires a 64-bit data type and is not compatible with pure C89
|
||||
platforms.
|
||||
|
@ -199,20 +197,11 @@ parameter is a buffer with either 1 or 4 bytes.)
|
|||
|
||||
Murmur3's function prototypes are::
|
||||
|
||||
void MurmurHash3_x86_32(const void *key,
|
||||
int len,
|
||||
uint32_t seed,
|
||||
void *out);
|
||||
void MurmurHash3_x86_32(const void *key, int len, uint32_t seed, void *out)
|
||||
|
||||
void MurmurHash3_x86_128(const void * key,
|
||||
int len,
|
||||
uint32_t seed,
|
||||
void *out);
|
||||
void MurmurHash3_x86_128(const void *key, int len, uint32_t seed, void *out)
|
||||
|
||||
void MurmurHash3_x64_128(const void *key,
|
||||
int len,
|
||||
uint32_t seed,
|
||||
void *out);
|
||||
void MurmurHash3_x64_128(const void *key, int len, uint32_t seed, void *out)
|
||||
|
||||
The 128-bit variants requires a 64-bit data type and are not compatible with
|
||||
pure C89 platforms. The 32-bit variant is fully C89-compatible.
|
||||
|
@ -234,10 +223,8 @@ MurmurHash and claims to be faster. It supports 64- and 128-bit output with a
|
|||
|
||||
The relevant function prototype for 64-bit CityHash with 128-bit seed is::
|
||||
|
||||
uint64 CityHash64WithSeeds(const char *buf,
|
||||
size_t len,
|
||||
uint64 seed0,
|
||||
uint64 seed1)
|
||||
uint64 CityHash64WithSeeds(const char *buf, size_t len, uint64 seed0,
|
||||
uint64 seed1)
|
||||
|
||||
CityHash also offers SSE 4.2 optimizations with CRC32 intrinsic for long
|
||||
inputs. All variants except CityHash32 require 64-bit data types. CityHash32
|
||||
|
@ -253,19 +240,14 @@ DJBX33A
|
|||
TODO
|
||||
|
||||
|
||||
HMAC, MD5, SHA-1, SHA-2
|
||||
-----------------------
|
||||
Other
|
||||
-----
|
||||
|
||||
These hash algorithms are too slow and have high setup and finalization costs.
|
||||
For these reasons they are not considered fit for this purpose.
|
||||
|
||||
|
||||
AES CMAC
|
||||
--------
|
||||
|
||||
Modern AMD and Intel CPUs have AES-NI (AES instruction set) [aes-ni]_ to speed
|
||||
up AES encryption. CMAC with AES-NI might be a viable option but it's probably
|
||||
too slow for daily operation. (testing required)
|
||||
Crypto algorithms such as HMAC, MD5, SHA-1 or SHA-2 are too slow and have
|
||||
high setup and finalization costs. For these reasons they are not considered
|
||||
fit for this purpose. Modern AMD and Intel CPUs have AES-NI (AES instruction
|
||||
set) [aes-ni]_ to speed up AES encryption. CMAC with AES-NI might be a viable
|
||||
option but it's probably too slow for daily operation. (testing required)
|
||||
|
||||
|
||||
Conclusion
|
||||
|
@ -473,7 +455,7 @@ for ``unsigned char *``.
|
|||
The function is moved to Python/pyhash.c and modified to use the hash function
|
||||
through PyHash_Func.hash(). The function signature is altered to take
|
||||
a ``const void *`` as first argument. ``_Py_HashBytes`` also takes care of
|
||||
special cases. It maps zero length input to ``0`` and return value of ``-1``
|
||||
special cases: it maps zero length input to ``0`` and return value of ``-1``
|
||||
to ``-2``.
|
||||
|
||||
bytes_hash() (Objects/bytesobject.c)
|
||||
|
|
Loading…
Reference in New Issue