├── LICENSE ├── MANIFEST.in ├── city.cc ├── city.h ├── cityhash.cpp ├── cityhash.pyx └── setup.py /LICENSE: -------------------------------------------------------------------------------- 1 | CityHash.py - Python-bindings for CityHash 2 | 3 | Copyright (c) 2011, Alexander Marshalov , 4 | except where the file explicitly names other copyright holders and licenses. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | 11 | the Software, and to permit persons to whom the Software is furnished to do so, 12 | subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | 20 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 21 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 22 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.h -------------------------------------------------------------------------------- /city.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 Google, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | // CityHash Version 1, by Geoff Pike and Jyrki Alakuijala 22 | // 23 | // This file provides CityHash64() and related functions. 24 | // 25 | // It's probably possible to create even faster hash functions by 26 | // writing a program that systematically explores some of the space of 27 | // possible hash functions, by using SIMD instructions, or by 28 | // compromising on hash quality. 29 | 30 | #include "city.h" 31 | 32 | #include 33 | 34 | using namespace std; 35 | 36 | #define UNALIGNED_LOAD64(p) (*(const uint64*)(p)) 37 | #define UNALIGNED_LOAD32(p) (*(const uint32*)(p)) 38 | 39 | #if !defined(LIKELY) 40 | #if defined(__GNUC__) 41 | #define LIKELY(x) (__builtin_expect(!!(x), 1)) 42 | #else 43 | #define LIKELY(x) (x) 44 | #endif 45 | #endif 46 | 47 | // Some primes between 2^63 and 2^64 for various uses. 48 | static const uint64 k0 = 0xc3a5c85c97cb3127ULL; 49 | static const uint64 k1 = 0xb492b66fbe98f273ULL; 50 | static const uint64 k2 = 0x9ae16a3b2f90404fULL; 51 | static const uint64 k3 = 0xc949d7c7509e6557ULL; 52 | 53 | // Bitwise right rotate. Normally this will compile to a single 54 | // instruction, especially if the shift is a manifest constant. 55 | static uint64 Rotate(uint64 val, int shift) { 56 | // Avoid shifting by 64: doing so yields an undefined result. 57 | return shift == 0 ? val : ((val >> shift) | (val << (64 - shift))); 58 | } 59 | 60 | // Equivalent to Rotate(), but requires the second arg to be non-zero. 61 | // On x86-64, and probably others, it's possible for this to compile 62 | // to a single instruction if both args are already in registers. 63 | static uint64 RotateByAtLeast1(uint64 val, int shift) { 64 | return (val >> shift) | (val << (64 - shift)); 65 | } 66 | 67 | static uint64 ShiftMix(uint64 val) { 68 | return val ^ (val >> 47); 69 | } 70 | 71 | static uint64 HashLen16(uint64 u, uint64 v) { 72 | return Hash128to64(uint128(u, v)); 73 | } 74 | 75 | static uint64 HashLen0to16(const char *s, size_t len) { 76 | if (len > 8) { 77 | uint64 a = UNALIGNED_LOAD64(s); 78 | uint64 b = UNALIGNED_LOAD64(s + len - 8); 79 | return HashLen16(a, RotateByAtLeast1(b + len, len)) ^ b; 80 | } 81 | if (len >= 4) { 82 | uint64 a = UNALIGNED_LOAD32(s); 83 | return HashLen16(len + (a << 3), UNALIGNED_LOAD32(s + len - 4)); 84 | } 85 | if (len > 0) { 86 | uint8 a = s[0]; 87 | uint8 b = s[len >> 1]; 88 | uint8 c = s[len - 1]; 89 | uint32 y = static_cast(a) + (static_cast(b) << 8); 90 | uint32 z = len + (static_cast(c) << 2); 91 | return ShiftMix(y * k2 ^ z * k3) * k2; 92 | } 93 | return k2; 94 | } 95 | 96 | // This probably works well for 16-byte strings as well, but it may be overkill 97 | // in that case. 98 | static uint64 HashLen17to32(const char *s, size_t len) { 99 | uint64 a = UNALIGNED_LOAD64(s) * k1; 100 | uint64 b = UNALIGNED_LOAD64(s + 8); 101 | uint64 c = UNALIGNED_LOAD64(s + len - 8) * k2; 102 | uint64 d = UNALIGNED_LOAD64(s + len - 16) * k0; 103 | return HashLen16(Rotate(a - b, 43) + Rotate(c, 30) + d, 104 | a + Rotate(b ^ k3, 20) - c + len); 105 | } 106 | 107 | // Return a 16-byte hash for 48 bytes. Quick and dirty. 108 | // Callers do best to use "random-looking" values for a and b. 109 | static pair WeakHashLen32WithSeeds( 110 | uint64 w, uint64 x, uint64 y, uint64 z, uint64 a, uint64 b) { 111 | a += w; 112 | b = Rotate(b + a + z, 21); 113 | uint64 c = a; 114 | a += x; 115 | a += y; 116 | b += Rotate(a, 44); 117 | return make_pair(a + z, b + c); 118 | } 119 | 120 | // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. 121 | static pair WeakHashLen32WithSeeds( 122 | const char* s, uint64 a, uint64 b) { 123 | return WeakHashLen32WithSeeds(UNALIGNED_LOAD64(s), 124 | UNALIGNED_LOAD64(s + 8), 125 | UNALIGNED_LOAD64(s + 16), 126 | UNALIGNED_LOAD64(s + 24), 127 | a, 128 | b); 129 | } 130 | 131 | // Return an 8-byte hash for 33 to 64 bytes. 132 | static uint64 HashLen33to64(const char *s, size_t len) { 133 | uint64 z = UNALIGNED_LOAD64(s + 24); 134 | uint64 a = UNALIGNED_LOAD64(s) + (len + UNALIGNED_LOAD64(s + len - 16)) * k0; 135 | uint64 b = Rotate(a + z, 52); 136 | uint64 c = Rotate(a, 37); 137 | a += UNALIGNED_LOAD64(s + 8); 138 | c += Rotate(a, 7); 139 | a += UNALIGNED_LOAD64(s + 16); 140 | uint64 vf = a + z; 141 | uint64 vs = b + Rotate(a, 31) + c; 142 | a = UNALIGNED_LOAD64(s + 16) + UNALIGNED_LOAD64(s + len - 32); 143 | z = UNALIGNED_LOAD64(s + len - 8); 144 | b = Rotate(a + z, 52); 145 | c = Rotate(a, 37); 146 | a += UNALIGNED_LOAD64(s + len - 24); 147 | c += Rotate(a, 7); 148 | a += UNALIGNED_LOAD64(s + len - 16); 149 | uint64 wf = a + z; 150 | uint64 ws = b + Rotate(a, 31) + c; 151 | uint64 r = ShiftMix((vf + ws) * k2 + (wf + vs) * k0); 152 | return ShiftMix(r * k0 + vs) * k2; 153 | } 154 | 155 | uint64 CityHash64(const char *s, size_t len) { 156 | if (len <= 32) { 157 | if (len <= 16) { 158 | return HashLen0to16(s, len); 159 | } else { 160 | return HashLen17to32(s, len); 161 | } 162 | } else if (len <= 64) { 163 | return HashLen33to64(s, len); 164 | } 165 | 166 | // For strings over 64 bytes we hash the end first, and then as we 167 | // loop we keep 56 bytes of state: v, w, x, y, and z. 168 | uint64 x = UNALIGNED_LOAD64(s); 169 | uint64 y = UNALIGNED_LOAD64(s + len - 16) ^ k1; 170 | uint64 z = UNALIGNED_LOAD64(s + len - 56) ^ k0; 171 | pair v = WeakHashLen32WithSeeds(s + len - 64, len, y); 172 | pair w = WeakHashLen32WithSeeds(s + len - 32, len * k1, k0); 173 | z += ShiftMix(v.second) * k1; 174 | x = Rotate(z + x, 39) * k1; 175 | y = Rotate(y, 33) * k1; 176 | 177 | // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. 178 | len = (len - 1) & ~static_cast(63); 179 | do { 180 | x = Rotate(x + y + v.first + UNALIGNED_LOAD64(s + 16), 37) * k1; 181 | y = Rotate(y + v.second + UNALIGNED_LOAD64(s + 48), 42) * k1; 182 | x ^= w.second; 183 | y ^= v.first; 184 | z = Rotate(z ^ w.first, 33); 185 | v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first); 186 | w = WeakHashLen32WithSeeds(s + 32, z + w.second, y); 187 | std::swap(z, x); 188 | s += 64; 189 | len -= 64; 190 | } while (len != 0); 191 | return HashLen16(HashLen16(v.first, w.first) + ShiftMix(y) * k1 + z, 192 | HashLen16(v.second, w.second) + x); 193 | } 194 | 195 | uint64 CityHash64WithSeed(const char *s, size_t len, uint64 seed) { 196 | return CityHash64WithSeeds(s, len, k2, seed); 197 | } 198 | 199 | uint64 CityHash64WithSeeds(const char *s, size_t len, 200 | uint64 seed0, uint64 seed1) { 201 | return HashLen16(CityHash64(s, len) - seed0, seed1); 202 | } 203 | 204 | // A subroutine for CityHash128(). Returns a decent 128-bit hash for strings 205 | // of any length representable in ssize_t. Based on City and Murmur. 206 | static uint128 CityMurmur(const char *s, size_t len, uint128 seed) { 207 | uint64 a = Uint128Low64(seed); 208 | uint64 b = Uint128High64(seed); 209 | uint64 c = 0; 210 | uint64 d = 0; 211 | size_t l = len - 16; 212 | if (l <= 0) { // len <= 16 213 | c = b * k1 + HashLen0to16(s, len); 214 | d = Rotate(a + (len >= 8 ? UNALIGNED_LOAD64(s) : c), 32); 215 | } else { // len > 16 216 | c = HashLen16(UNALIGNED_LOAD64(s + len - 8) + k1, a); 217 | d = HashLen16(b + len, c + UNALIGNED_LOAD64(s + len - 16)); 218 | a += d; 219 | do { 220 | a ^= ShiftMix(UNALIGNED_LOAD64(s) * k1) * k1; 221 | a *= k1; 222 | b ^= a; 223 | c ^= ShiftMix(UNALIGNED_LOAD64(s + 8) * k1) * k1; 224 | c *= k1; 225 | d ^= c; 226 | s += 16; 227 | l -= 16; 228 | } while (l > 0); 229 | } 230 | a = HashLen16(a, c); 231 | b = HashLen16(d, b); 232 | return uint128(a ^ b, HashLen16(b, a)); 233 | } 234 | 235 | uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed) { 236 | if (len < 128) { 237 | return CityMurmur(s, len, seed); 238 | } 239 | 240 | // We expect len >= 128 to be the common case. Keep 56 bytes of state: 241 | // v, w, x, y, and z. 242 | pair v, w; 243 | uint64 x = Uint128Low64(seed); 244 | uint64 y = Uint128High64(seed); 245 | uint64 z = len * k1; 246 | v.first = Rotate(y ^ k1, 49) * k1 + UNALIGNED_LOAD64(s); 247 | v.second = Rotate(v.first, 42) * k1 + UNALIGNED_LOAD64(s + 8); 248 | w.first = Rotate(y + z, 35) * k1 + x; 249 | w.second = Rotate(x + UNALIGNED_LOAD64(s + 88), 53) * k1; 250 | 251 | // This is the same inner loop as CityHash64(), manually unrolled. 252 | do { 253 | x = Rotate(x + y + v.first + UNALIGNED_LOAD64(s + 16), 37) * k1; 254 | y = Rotate(y + v.second + UNALIGNED_LOAD64(s + 48), 42) * k1; 255 | x ^= w.second; 256 | y ^= v.first; 257 | z = Rotate(z ^ w.first, 33); 258 | v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first); 259 | w = WeakHashLen32WithSeeds(s + 32, z + w.second, y); 260 | std::swap(z, x); 261 | s += 64; 262 | x = Rotate(x + y + v.first + UNALIGNED_LOAD64(s + 16), 37) * k1; 263 | y = Rotate(y + v.second + UNALIGNED_LOAD64(s + 48), 42) * k1; 264 | x ^= w.second; 265 | y ^= v.first; 266 | z = Rotate(z ^ w.first, 33); 267 | v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first); 268 | w = WeakHashLen32WithSeeds(s + 32, z + w.second, y); 269 | std::swap(z, x); 270 | s += 64; 271 | len -= 128; 272 | } while (LIKELY(len >= 128)); 273 | y += Rotate(w.first, 37) * k0 + z; 274 | x += Rotate(v.first + z, 49) * k0; 275 | // If 0 < len < 128, hash up to 4 chunks of 32 bytes each from the end of s. 276 | for (size_t tail_done = 0; tail_done < len; ) { 277 | tail_done += 32; 278 | y = Rotate(y - x, 42) * k0 + v.second; 279 | w.first += UNALIGNED_LOAD64(s + len - tail_done + 16); 280 | x = Rotate(x, 49) * k0 + w.first; 281 | w.first += v.first; 282 | v = WeakHashLen32WithSeeds(s + len - tail_done, v.first, v.second); 283 | } 284 | // At this point our 48 bytes of state should contain more than 285 | // enough information for a strong 128-bit hash. We use two 286 | // different 48-byte-to-8-byte hashes to get a 16-byte final result. 287 | x = HashLen16(x, v.first); 288 | y = HashLen16(y, w.first); 289 | return uint128(HashLen16(x + v.second, w.second) + y, 290 | HashLen16(x + w.second, y + v.second)); 291 | } 292 | 293 | uint128 CityHash128(const char *s, size_t len) { 294 | if (len >= 16) { 295 | return CityHash128WithSeed(s + 16, 296 | len - 16, 297 | uint128(UNALIGNED_LOAD64(s) ^ k3, 298 | UNALIGNED_LOAD64(s + 8))); 299 | } else if (len >= 8) { 300 | return CityHash128WithSeed(NULL, 301 | 0, 302 | uint128(UNALIGNED_LOAD64(s) ^ (len * k0), 303 | UNALIGNED_LOAD64(s + len - 8) ^ k1)); 304 | } else { 305 | return CityHash128WithSeed(s, len, uint128(k0, k1)); 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /city.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 Google, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | // CityHash Version 1, by Geoff Pike and Jyrki Alakuijala 22 | // 23 | // This file provides a few functions for hashing strings. On x86-64 24 | // hardware in 2011, CityHash64() is faster than other high-quality 25 | // hash functions, such as Murmur. This is largely due to higher 26 | // instruction-level parallelism. CityHash64() and CityHash128() also perform 27 | // well on hash-quality tests. 28 | // 29 | // CityHash128() is optimized for relatively long strings and returns 30 | // a 128-bit hash. For strings more than about 2000 bytes it can be 31 | // faster than CityHash64(). 32 | // 33 | // Functions in the CityHash family are not suitable for cryptography. 34 | // 35 | // WARNING: This code has not been tested on big-endian platforms! 36 | // It is known to work well on little-endian platforms that have a small penalty 37 | // for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs. 38 | // 39 | // By the way, for some hash functions, given strings a and b, the hash 40 | // of a+b is easily derived from the hashes of a and b. This property 41 | // doesn't hold for any hash functions in this file. 42 | 43 | #ifndef CITY_HASH_H_ 44 | #define CITY_HASH_H_ 45 | 46 | #include // for size_t. 47 | #include 48 | #include 49 | 50 | typedef uint8_t uint8; 51 | typedef uint32_t uint32; 52 | typedef uint64_t uint64; 53 | typedef std::pair uint128; 54 | 55 | inline uint64 Uint128Low64(const uint128& x) { return x.first; } 56 | inline uint64 Uint128High64(const uint128& x) { return x.second; } 57 | 58 | // Hash function for a byte array. 59 | uint64 CityHash64(const char *buf, size_t len); 60 | 61 | // Hash function for a byte array. For convenience, a 64-bit seed is also 62 | // hashed into the result. 63 | uint64 CityHash64WithSeed(const char *buf, size_t len, uint64 seed); 64 | 65 | // Hash function for a byte array. For convenience, two seeds are also 66 | // hashed into the result. 67 | uint64 CityHash64WithSeeds(const char *buf, size_t len, 68 | uint64 seed0, uint64 seed1); 69 | 70 | // Hash function for a byte array. 71 | uint128 CityHash128(const char *s, size_t len); 72 | 73 | // Hash function for a byte array. For convenience, a 128-bit seed is also 74 | // hashed into the result. 75 | uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed); 76 | 77 | // Hash 128 input bits down to 64 bits of output. 78 | // This is intended to be a reasonably good hash function. 79 | inline uint64 Hash128to64(const uint128& x) { 80 | // Murmur-inspired hashing. 81 | const uint64 kMul = 0x9ddfea08eb382d69ULL; 82 | uint64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul; 83 | a ^= (a >> 47); 84 | uint64 b = (Uint128High64(x) ^ a) * kMul; 85 | b ^= (b >> 47); 86 | b *= kMul; 87 | return b; 88 | } 89 | 90 | #endif // CITY_HASH_H_ 91 | -------------------------------------------------------------------------------- /cityhash.cpp: -------------------------------------------------------------------------------- 1 | /* Generated by Cython 0.15.1 on Wed Jan 18 15:04:57 2012 */ 2 | 3 | #define PY_SSIZE_T_CLEAN 4 | #include "Python.h" 5 | #ifndef Py_PYTHON_H 6 | #error Python headers needed to compile C extensions, please install development version of Python. 7 | #else 8 | 9 | #include /* For offsetof */ 10 | #ifndef offsetof 11 | #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) 12 | #endif 13 | 14 | #if !defined(WIN32) && !defined(MS_WINDOWS) 15 | #ifndef __stdcall 16 | #define __stdcall 17 | #endif 18 | #ifndef __cdecl 19 | #define __cdecl 20 | #endif 21 | #ifndef __fastcall 22 | #define __fastcall 23 | #endif 24 | #endif 25 | 26 | #ifndef DL_IMPORT 27 | #define DL_IMPORT(t) t 28 | #endif 29 | #ifndef DL_EXPORT 30 | #define DL_EXPORT(t) t 31 | #endif 32 | 33 | #ifndef PY_LONG_LONG 34 | #define PY_LONG_LONG LONG_LONG 35 | #endif 36 | 37 | #if PY_VERSION_HEX < 0x02040000 38 | #define METH_COEXIST 0 39 | #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) 40 | #define PyDict_Contains(d,o) PySequence_Contains(d,o) 41 | #endif 42 | 43 | #if PY_VERSION_HEX < 0x02050000 44 | typedef int Py_ssize_t; 45 | #define PY_SSIZE_T_MAX INT_MAX 46 | #define PY_SSIZE_T_MIN INT_MIN 47 | #define PY_FORMAT_SIZE_T "" 48 | #define PyInt_FromSsize_t(z) PyInt_FromLong(z) 49 | #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) 50 | #define PyNumber_Index(o) PyNumber_Int(o) 51 | #define PyIndex_Check(o) PyNumber_Check(o) 52 | #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) 53 | #endif 54 | 55 | #if PY_VERSION_HEX < 0x02060000 56 | #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) 57 | #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) 58 | #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) 59 | #define PyVarObject_HEAD_INIT(type, size) \ 60 | PyObject_HEAD_INIT(type) size, 61 | #define PyType_Modified(t) 62 | 63 | typedef struct { 64 | void *buf; 65 | PyObject *obj; 66 | Py_ssize_t len; 67 | Py_ssize_t itemsize; 68 | int readonly; 69 | int ndim; 70 | char *format; 71 | Py_ssize_t *shape; 72 | Py_ssize_t *strides; 73 | Py_ssize_t *suboffsets; 74 | void *internal; 75 | } Py_buffer; 76 | 77 | #define PyBUF_SIMPLE 0 78 | #define PyBUF_WRITABLE 0x0001 79 | #define PyBUF_FORMAT 0x0004 80 | #define PyBUF_ND 0x0008 81 | #define PyBUF_STRIDES (0x0010 | PyBUF_ND) 82 | #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) 83 | #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) 84 | #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) 85 | #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) 86 | 87 | #endif 88 | 89 | #if PY_MAJOR_VERSION < 3 90 | #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" 91 | #else 92 | #define __Pyx_BUILTIN_MODULE_NAME "builtins" 93 | #endif 94 | 95 | #if PY_MAJOR_VERSION >= 3 96 | #define Py_TPFLAGS_CHECKTYPES 0 97 | #define Py_TPFLAGS_HAVE_INDEX 0 98 | #endif 99 | 100 | #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) 101 | #define Py_TPFLAGS_HAVE_NEWBUFFER 0 102 | #endif 103 | 104 | #if PY_MAJOR_VERSION >= 3 105 | #define PyBaseString_Type PyUnicode_Type 106 | #define PyStringObject PyUnicodeObject 107 | #define PyString_Type PyUnicode_Type 108 | #define PyString_Check PyUnicode_Check 109 | #define PyString_CheckExact PyUnicode_CheckExact 110 | #endif 111 | 112 | #if PY_VERSION_HEX < 0x02060000 113 | #define PyBytesObject PyStringObject 114 | #define PyBytes_Type PyString_Type 115 | #define PyBytes_Check PyString_Check 116 | #define PyBytes_CheckExact PyString_CheckExact 117 | #define PyBytes_FromString PyString_FromString 118 | #define PyBytes_FromStringAndSize PyString_FromStringAndSize 119 | #define PyBytes_FromFormat PyString_FromFormat 120 | #define PyBytes_DecodeEscape PyString_DecodeEscape 121 | #define PyBytes_AsString PyString_AsString 122 | #define PyBytes_AsStringAndSize PyString_AsStringAndSize 123 | #define PyBytes_Size PyString_Size 124 | #define PyBytes_AS_STRING PyString_AS_STRING 125 | #define PyBytes_GET_SIZE PyString_GET_SIZE 126 | #define PyBytes_Repr PyString_Repr 127 | #define PyBytes_Concat PyString_Concat 128 | #define PyBytes_ConcatAndDel PyString_ConcatAndDel 129 | #endif 130 | 131 | #if PY_VERSION_HEX < 0x02060000 132 | #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) 133 | #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) 134 | #endif 135 | #ifndef PySet_CheckExact 136 | #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) 137 | #endif 138 | 139 | #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) 140 | 141 | #if PY_MAJOR_VERSION >= 3 142 | #define PyIntObject PyLongObject 143 | #define PyInt_Type PyLong_Type 144 | #define PyInt_Check(op) PyLong_Check(op) 145 | #define PyInt_CheckExact(op) PyLong_CheckExact(op) 146 | #define PyInt_FromString PyLong_FromString 147 | #define PyInt_FromUnicode PyLong_FromUnicode 148 | #define PyInt_FromLong PyLong_FromLong 149 | #define PyInt_FromSize_t PyLong_FromSize_t 150 | #define PyInt_FromSsize_t PyLong_FromSsize_t 151 | #define PyInt_AsLong PyLong_AsLong 152 | #define PyInt_AS_LONG PyLong_AS_LONG 153 | #define PyInt_AsSsize_t PyLong_AsSsize_t 154 | #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask 155 | #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask 156 | #endif 157 | 158 | #if PY_MAJOR_VERSION >= 3 159 | #define PyBoolObject PyLongObject 160 | #endif 161 | 162 | #if PY_VERSION_HEX < 0x03020000 163 | typedef long Py_hash_t; 164 | #define __Pyx_PyInt_FromHash_t PyInt_FromLong 165 | #define __Pyx_PyInt_AsHash_t PyInt_AsLong 166 | #else 167 | #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t 168 | #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t 169 | #endif 170 | 171 | 172 | #if PY_MAJOR_VERSION >= 3 173 | #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) 174 | #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) 175 | #else 176 | #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) 177 | #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) 178 | #endif 179 | 180 | #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) 181 | #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) 182 | #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) 183 | #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) 184 | #else 185 | #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ 186 | (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ 187 | (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ 188 | (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) 189 | #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ 190 | (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ 191 | (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ 192 | (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) 193 | #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ 194 | (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ 195 | (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ 196 | (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) 197 | #endif 198 | 199 | #if PY_MAJOR_VERSION >= 3 200 | #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) 201 | #endif 202 | 203 | #if PY_VERSION_HEX < 0x02050000 204 | #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) 205 | #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) 206 | #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) 207 | #else 208 | #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) 209 | #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) 210 | #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) 211 | #endif 212 | 213 | #if PY_VERSION_HEX < 0x02050000 214 | #define __Pyx_NAMESTR(n) ((char *)(n)) 215 | #define __Pyx_DOCSTR(n) ((char *)(n)) 216 | #else 217 | #define __Pyx_NAMESTR(n) (n) 218 | #define __Pyx_DOCSTR(n) (n) 219 | #endif 220 | 221 | #ifndef __PYX_EXTERN_C 222 | #ifdef __cplusplus 223 | #define __PYX_EXTERN_C extern "C" 224 | #else 225 | #define __PYX_EXTERN_C extern 226 | #endif 227 | #endif 228 | 229 | #if defined(WIN32) || defined(MS_WINDOWS) 230 | #define _USE_MATH_DEFINES 231 | #endif 232 | #include 233 | #define __PYX_HAVE__cityhash 234 | #define __PYX_HAVE_API__cityhash 235 | #include "city.h" 236 | #include 237 | #ifdef _OPENMP 238 | #include 239 | #endif /* _OPENMP */ 240 | 241 | #ifdef PYREX_WITHOUT_ASSERTIONS 242 | #define CYTHON_WITHOUT_ASSERTIONS 243 | #endif 244 | 245 | 246 | /* inline attribute */ 247 | #ifndef CYTHON_INLINE 248 | #if defined(__GNUC__) 249 | #define CYTHON_INLINE __inline__ 250 | #elif defined(_MSC_VER) 251 | #define CYTHON_INLINE __inline 252 | #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 253 | #define CYTHON_INLINE inline 254 | #else 255 | #define CYTHON_INLINE 256 | #endif 257 | #endif 258 | 259 | /* unused attribute */ 260 | #ifndef CYTHON_UNUSED 261 | # if defined(__GNUC__) 262 | # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 263 | # define CYTHON_UNUSED __attribute__ ((__unused__)) 264 | # else 265 | # define CYTHON_UNUSED 266 | # endif 267 | # elif defined(__ICC) || defined(__INTEL_COMPILER) 268 | # define CYTHON_UNUSED __attribute__ ((__unused__)) 269 | # else 270 | # define CYTHON_UNUSED 271 | # endif 272 | #endif 273 | 274 | typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ 275 | 276 | 277 | /* Type Conversion Predeclarations */ 278 | 279 | #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s) 280 | #define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s)) 281 | 282 | #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) 283 | #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) 284 | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); 285 | static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); 286 | 287 | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); 288 | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); 289 | static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); 290 | 291 | #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) 292 | 293 | 294 | #ifdef __GNUC__ 295 | /* Test for GCC > 2.95 */ 296 | #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 297 | #define likely(x) __builtin_expect(!!(x), 1) 298 | #define unlikely(x) __builtin_expect(!!(x), 0) 299 | #else /* __GNUC__ > 2 ... */ 300 | #define likely(x) (x) 301 | #define unlikely(x) (x) 302 | #endif /* __GNUC__ > 2 ... */ 303 | #else /* __GNUC__ */ 304 | #define likely(x) (x) 305 | #define unlikely(x) (x) 306 | #endif /* __GNUC__ */ 307 | 308 | static PyObject *__pyx_m; 309 | static PyObject *__pyx_b; 310 | static PyObject *__pyx_empty_tuple; 311 | static PyObject *__pyx_empty_bytes; 312 | static int __pyx_lineno; 313 | static int __pyx_clineno = 0; 314 | static const char * __pyx_cfilenm= __FILE__; 315 | static const char *__pyx_filename; 316 | 317 | 318 | static const char *__pyx_f[] = { 319 | "cityhash.pyx", 320 | }; 321 | 322 | /*--- Type declarations ---*/ 323 | struct __pyx_obj_8cityhash_ch128; 324 | struct __pyx_obj_8cityhash_ch64; 325 | 326 | /* "cityhash.pyx":130 327 | * return self.__value 328 | * 329 | * cdef class ch128: # <<<<<<<<<<<<<< 330 | * cdef tuple __value 331 | * cdef public bytes name 332 | */ 333 | struct __pyx_obj_8cityhash_ch128 { 334 | PyObject_HEAD 335 | struct __pyx_vtabstruct_8cityhash_ch128 *__pyx_vtab; 336 | PyObject *__pyx___value; 337 | PyObject *name; 338 | }; 339 | 340 | 341 | /* "cityhash.pyx":116 342 | * return c_Hash128to64(xx) 343 | * 344 | * cdef class ch64: # <<<<<<<<<<<<<< 345 | * cdef uint64 __value 346 | * cdef public bytes name 347 | */ 348 | struct __pyx_obj_8cityhash_ch64 { 349 | PyObject_HEAD 350 | struct __pyx_vtabstruct_8cityhash_ch64 *__pyx_vtab; 351 | uint64 __pyx___value; 352 | PyObject *name; 353 | }; 354 | 355 | 356 | 357 | struct __pyx_vtabstruct_8cityhash_ch64 { 358 | PyObject *(*update)(struct __pyx_obj_8cityhash_ch64 *, PyObject *, int __pyx_skip_dispatch); 359 | PyObject *(*digest)(struct __pyx_obj_8cityhash_ch64 *, int __pyx_skip_dispatch); 360 | }; 361 | static struct __pyx_vtabstruct_8cityhash_ch64 *__pyx_vtabptr_8cityhash_ch64; 362 | 363 | 364 | /* "cityhash.pyx":130 365 | * return self.__value 366 | * 367 | * cdef class ch128: # <<<<<<<<<<<<<< 368 | * cdef tuple __value 369 | * cdef public bytes name 370 | */ 371 | 372 | struct __pyx_vtabstruct_8cityhash_ch128 { 373 | PyObject *(*update)(struct __pyx_obj_8cityhash_ch128 *, PyObject *, int __pyx_skip_dispatch); 374 | PyObject *(*digest)(struct __pyx_obj_8cityhash_ch128 *, int __pyx_skip_dispatch); 375 | }; 376 | static struct __pyx_vtabstruct_8cityhash_ch128 *__pyx_vtabptr_8cityhash_ch128; 377 | 378 | #ifndef CYTHON_REFNANNY 379 | #define CYTHON_REFNANNY 0 380 | #endif 381 | 382 | #if CYTHON_REFNANNY 383 | typedef struct { 384 | void (*INCREF)(void*, PyObject*, int); 385 | void (*DECREF)(void*, PyObject*, int); 386 | void (*GOTREF)(void*, PyObject*, int); 387 | void (*GIVEREF)(void*, PyObject*, int); 388 | void* (*SetupContext)(const char*, int, const char*); 389 | void (*FinishContext)(void**); 390 | } __Pyx_RefNannyAPIStruct; 391 | static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; 392 | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ 393 | #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; 394 | #define __Pyx_RefNannySetupContext(name) __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) 395 | #define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny) 396 | #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 397 | #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 398 | #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 399 | #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 400 | #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) 401 | #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) 402 | #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) 403 | #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) 404 | #else 405 | #define __Pyx_RefNannyDeclarations 406 | #define __Pyx_RefNannySetupContext(name) 407 | #define __Pyx_RefNannyFinishContext() 408 | #define __Pyx_INCREF(r) Py_INCREF(r) 409 | #define __Pyx_DECREF(r) Py_DECREF(r) 410 | #define __Pyx_GOTREF(r) 411 | #define __Pyx_GIVEREF(r) 412 | #define __Pyx_XINCREF(r) Py_XINCREF(r) 413 | #define __Pyx_XDECREF(r) Py_XDECREF(r) 414 | #define __Pyx_XGOTREF(r) 415 | #define __Pyx_XGIVEREF(r) 416 | #endif /* CYTHON_REFNANNY */ 417 | 418 | static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, 419 | const char *name, int exact); /*proto*/ 420 | 421 | static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, 422 | Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ 423 | 424 | static void __Pyx_RaiseDoubleKeywordsError( 425 | const char* func_name, PyObject* kw_name); /*proto*/ 426 | 427 | static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/ 428 | 429 | 430 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { 431 | PyObject *r; 432 | if (!j) return NULL; 433 | r = PyObject_GetItem(o, j); 434 | Py_DECREF(j); 435 | return r; 436 | } 437 | 438 | 439 | #define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ 440 | __Pyx_GetItemInt_List_Fast(o, i) : \ 441 | __Pyx_GetItemInt_Generic(o, to_py_func(i))) 442 | 443 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) { 444 | if (likely(o != Py_None)) { 445 | if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { 446 | PyObject *r = PyList_GET_ITEM(o, i); 447 | Py_INCREF(r); 448 | return r; 449 | } 450 | else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) { 451 | PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i); 452 | Py_INCREF(r); 453 | return r; 454 | } 455 | } 456 | return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); 457 | } 458 | 459 | #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ 460 | __Pyx_GetItemInt_Tuple_Fast(o, i) : \ 461 | __Pyx_GetItemInt_Generic(o, to_py_func(i))) 462 | 463 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) { 464 | if (likely(o != Py_None)) { 465 | if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { 466 | PyObject *r = PyTuple_GET_ITEM(o, i); 467 | Py_INCREF(r); 468 | return r; 469 | } 470 | else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) { 471 | PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i); 472 | Py_INCREF(r); 473 | return r; 474 | } 475 | } 476 | return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); 477 | } 478 | 479 | 480 | #define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \ 481 | __Pyx_GetItemInt_Fast(o, i) : \ 482 | __Pyx_GetItemInt_Generic(o, to_py_func(i))) 483 | 484 | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) { 485 | PyObject *r; 486 | if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) { 487 | r = PyList_GET_ITEM(o, i); 488 | Py_INCREF(r); 489 | } 490 | else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { 491 | r = PyTuple_GET_ITEM(o, i); 492 | Py_INCREF(r); 493 | } 494 | else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) { 495 | r = PySequence_GetItem(o, i); 496 | } 497 | else { 498 | r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); 499 | } 500 | return r; 501 | } 502 | 503 | static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t); 504 | 505 | static CYTHON_INLINE uint64_t __Pyx_PyInt_from_py_uint64_t(PyObject *); 506 | 507 | static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); 508 | 509 | static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); 510 | 511 | static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); 512 | 513 | static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); 514 | 515 | static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); 516 | 517 | static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); 518 | 519 | static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); 520 | 521 | static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); 522 | 523 | static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); 524 | 525 | static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); 526 | 527 | static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); 528 | 529 | static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); 530 | 531 | static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); 532 | 533 | static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); 534 | 535 | static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); 536 | 537 | static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); 538 | 539 | static int __Pyx_check_binary_version(void); 540 | 541 | static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ 542 | 543 | static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno, 544 | int __pyx_lineno, const char *__pyx_filename); /*proto*/ 545 | 546 | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ 547 | 548 | /* Module declarations from 'cityhash' */ 549 | static PyTypeObject *__pyx_ptype_8cityhash_ch64 = 0; 550 | static PyTypeObject *__pyx_ptype_8cityhash_ch128 = 0; 551 | static PyObject *__pyx_f_8cityhash_CityHash64(PyObject *, int __pyx_skip_dispatch); /*proto*/ 552 | static PyObject *__pyx_f_8cityhash_CityHash64WithSeed(PyObject *, uint64, int __pyx_skip_dispatch); /*proto*/ 553 | static PyObject *__pyx_f_8cityhash_CityHash64WithSeeds(PyObject *, uint64, uint64, int __pyx_skip_dispatch); /*proto*/ 554 | static PyObject *__pyx_f_8cityhash_CityHash128(PyObject *, int __pyx_skip_dispatch); /*proto*/ 555 | static PyObject *__pyx_f_8cityhash_CityHash128WithSeed(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/ 556 | static PyObject *__pyx_f_8cityhash_Hash128to64(PyObject *, int __pyx_skip_dispatch); /*proto*/ 557 | #define __Pyx_MODULE_NAME "cityhash" 558 | int __pyx_module_is_main_cityhash = 0; 559 | 560 | /* Implementation of 'cityhash' */ 561 | static char __pyx_k_5[] = "\nCopyright (c) 2011 Alexander [Amper] Marshalov \n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"; 562 | static char __pyx_k_6[] = "Alexander [Amper] Marshalov"; 563 | static char __pyx_k_7[] = "alone.amper+cityhash@gmail.com"; 564 | static char __pyx_k_8[] = ""; 565 | static char __pyx_k__buf[] = "buf"; 566 | static char __pyx_k__ch64[] = "ch64"; 567 | static char __pyx_k__seed[] = "seed"; 568 | static char __pyx_k__ch128[] = "ch128"; 569 | static char __pyx_k__seed0[] = "seed0"; 570 | static char __pyx_k__seed1[] = "seed1"; 571 | static char __pyx_k__value[] = "value"; 572 | static char __pyx_k__digest[] = "digest"; 573 | static char __pyx_k__update[] = "update"; 574 | static char __pyx_k____all__[] = "__all__"; 575 | static char __pyx_k____main__[] = "__main__"; 576 | static char __pyx_k____test__[] = "__test__"; 577 | static char __pyx_k____email__[] = "__email__"; 578 | static char __pyx_k__CityHash64[] = "CityHash64"; 579 | static char __pyx_k____author__[] = "__author__"; 580 | static char __pyx_k__CityHash128[] = "CityHash128"; 581 | static char __pyx_k__Hash128to64[] = "Hash128to64"; 582 | static char __pyx_k__CityHash64WithSeed[] = "CityHash64WithSeed"; 583 | static char __pyx_k__CityHash128WithSeed[] = "CityHash128WithSeed"; 584 | static char __pyx_k__CityHash64WithSeeds[] = "CityHash64WithSeeds"; 585 | static PyObject *__pyx_kp_s_6; 586 | static PyObject *__pyx_kp_s_7; 587 | static PyObject *__pyx_kp_s_8; 588 | static PyObject *__pyx_n_s__CityHash128; 589 | static PyObject *__pyx_n_s__CityHash128WithSeed; 590 | static PyObject *__pyx_n_s__CityHash64; 591 | static PyObject *__pyx_n_s__CityHash64WithSeed; 592 | static PyObject *__pyx_n_s__CityHash64WithSeeds; 593 | static PyObject *__pyx_n_s__Hash128to64; 594 | static PyObject *__pyx_n_s____all__; 595 | static PyObject *__pyx_n_s____author__; 596 | static PyObject *__pyx_n_s____email__; 597 | static PyObject *__pyx_n_s____main__; 598 | static PyObject *__pyx_n_s____test__; 599 | static PyObject *__pyx_n_s__buf; 600 | static PyObject *__pyx_n_s__ch128; 601 | static PyObject *__pyx_n_s__ch64; 602 | static PyObject *__pyx_n_s__digest; 603 | static PyObject *__pyx_n_s__seed; 604 | static PyObject *__pyx_n_s__seed0; 605 | static PyObject *__pyx_n_s__seed1; 606 | static PyObject *__pyx_n_s__update; 607 | static PyObject *__pyx_n_s__value; 608 | static PyObject *__pyx_k_1; 609 | static PyObject *__pyx_k_3; 610 | static PyObject *__pyx_k_tuple_2; 611 | static PyObject *__pyx_k_tuple_4; 612 | static PyObject *__pyx_k_tuple_9; 613 | static PyObject *__pyx_k_tuple_10; 614 | 615 | /* "cityhash.pyx":70 616 | * cdef uint128[uint64,uint64] c_CityHash128WithSeed "CityHash128WithSeed" (char *s, size_t len, uint128[uint64,uint64] seed) 617 | * 618 | * cpdef CityHash64(bytes buf): # <<<<<<<<<<<<<< 619 | * """ 620 | * Description: Hash function for a byte array. 621 | */ 622 | 623 | static PyObject *__pyx_pf_8cityhash_CityHash64(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/ 624 | static PyObject *__pyx_f_8cityhash_CityHash64(PyObject *__pyx_v_buf, int __pyx_skip_dispatch) { 625 | PyObject *__pyx_r = NULL; 626 | __Pyx_RefNannyDeclarations 627 | char *__pyx_t_1; 628 | Py_ssize_t __pyx_t_2; 629 | PyObject *__pyx_t_3 = NULL; 630 | int __pyx_lineno = 0; 631 | const char *__pyx_filename = NULL; 632 | int __pyx_clineno = 0; 633 | __Pyx_RefNannySetupContext("CityHash64"); 634 | 635 | /* "cityhash.pyx":74 636 | * Description: Hash function for a byte array. 637 | * """ 638 | * return c_CityHash64(buf, len(buf)) # <<<<<<<<<<<<<< 639 | * 640 | * cpdef CityHash64WithSeed(bytes buf, uint64 seed): 641 | */ 642 | __Pyx_XDECREF(__pyx_r); 643 | __pyx_t_1 = PyBytes_AsString(((PyObject *)__pyx_v_buf)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 644 | if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { 645 | PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 646 | } 647 | __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_buf)); 648 | __pyx_t_3 = __Pyx_PyInt_to_py_uint64_t(CityHash64(__pyx_t_1, __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 649 | __Pyx_GOTREF(__pyx_t_3); 650 | __pyx_r = __pyx_t_3; 651 | __pyx_t_3 = 0; 652 | goto __pyx_L0; 653 | 654 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 655 | goto __pyx_L0; 656 | __pyx_L1_error:; 657 | __Pyx_XDECREF(__pyx_t_3); 658 | __Pyx_AddTraceback("cityhash.CityHash64", __pyx_clineno, __pyx_lineno, __pyx_filename); 659 | __pyx_r = 0; 660 | __pyx_L0:; 661 | __Pyx_XGIVEREF(__pyx_r); 662 | __Pyx_RefNannyFinishContext(); 663 | return __pyx_r; 664 | } 665 | 666 | /* "cityhash.pyx":70 667 | * cdef uint128[uint64,uint64] c_CityHash128WithSeed "CityHash128WithSeed" (char *s, size_t len, uint128[uint64,uint64] seed) 668 | * 669 | * cpdef CityHash64(bytes buf): # <<<<<<<<<<<<<< 670 | * """ 671 | * Description: Hash function for a byte array. 672 | */ 673 | 674 | static PyObject *__pyx_pf_8cityhash_CityHash64(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/ 675 | static char __pyx_doc_8cityhash_CityHash64[] = "\n Description: Hash function for a byte array.\n "; 676 | static PyObject *__pyx_pf_8cityhash_CityHash64(PyObject *__pyx_self, PyObject *__pyx_v_buf) { 677 | PyObject *__pyx_r = NULL; 678 | __Pyx_RefNannyDeclarations 679 | PyObject *__pyx_t_1 = NULL; 680 | int __pyx_lineno = 0; 681 | const char *__pyx_filename = NULL; 682 | int __pyx_clineno = 0; 683 | __Pyx_RefNannySetupContext("CityHash64"); 684 | __pyx_self = __pyx_self; 685 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buf), (&PyBytes_Type), 1, "buf", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 686 | __Pyx_XDECREF(__pyx_r); 687 | __pyx_t_1 = __pyx_f_8cityhash_CityHash64(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 688 | __Pyx_GOTREF(__pyx_t_1); 689 | __pyx_r = __pyx_t_1; 690 | __pyx_t_1 = 0; 691 | goto __pyx_L0; 692 | 693 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 694 | goto __pyx_L0; 695 | __pyx_L1_error:; 696 | __Pyx_XDECREF(__pyx_t_1); 697 | __Pyx_AddTraceback("cityhash.CityHash64", __pyx_clineno, __pyx_lineno, __pyx_filename); 698 | __pyx_r = NULL; 699 | __pyx_L0:; 700 | __Pyx_XGIVEREF(__pyx_r); 701 | __Pyx_RefNannyFinishContext(); 702 | return __pyx_r; 703 | } 704 | 705 | /* "cityhash.pyx":76 706 | * return c_CityHash64(buf, len(buf)) 707 | * 708 | * cpdef CityHash64WithSeed(bytes buf, uint64 seed): # <<<<<<<<<<<<<< 709 | * """ 710 | * Description: Hash function for a byte array. For convenience, a 64-bit seed is also 711 | */ 712 | 713 | static PyObject *__pyx_pf_8cityhash_1CityHash64WithSeed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 714 | static PyObject *__pyx_f_8cityhash_CityHash64WithSeed(PyObject *__pyx_v_buf, uint64 __pyx_v_seed, int __pyx_skip_dispatch) { 715 | PyObject *__pyx_r = NULL; 716 | __Pyx_RefNannyDeclarations 717 | char *__pyx_t_1; 718 | Py_ssize_t __pyx_t_2; 719 | PyObject *__pyx_t_3 = NULL; 720 | int __pyx_lineno = 0; 721 | const char *__pyx_filename = NULL; 722 | int __pyx_clineno = 0; 723 | __Pyx_RefNannySetupContext("CityHash64WithSeed"); 724 | 725 | /* "cityhash.pyx":81 726 | * hashed into the result. 727 | * """ 728 | * return c_CityHash64WithSeed(buf, len(buf), seed) # <<<<<<<<<<<<<< 729 | * 730 | * cpdef CityHash64WithSeeds(bytes buf, uint64 seed0, uint64 seed1): 731 | */ 732 | __Pyx_XDECREF(__pyx_r); 733 | __pyx_t_1 = PyBytes_AsString(((PyObject *)__pyx_v_buf)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 734 | if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { 735 | PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 736 | } 737 | __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_buf)); 738 | __pyx_t_3 = __Pyx_PyInt_to_py_uint64_t(CityHash64WithSeed(__pyx_t_1, __pyx_t_2, __pyx_v_seed)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 739 | __Pyx_GOTREF(__pyx_t_3); 740 | __pyx_r = __pyx_t_3; 741 | __pyx_t_3 = 0; 742 | goto __pyx_L0; 743 | 744 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 745 | goto __pyx_L0; 746 | __pyx_L1_error:; 747 | __Pyx_XDECREF(__pyx_t_3); 748 | __Pyx_AddTraceback("cityhash.CityHash64WithSeed", __pyx_clineno, __pyx_lineno, __pyx_filename); 749 | __pyx_r = 0; 750 | __pyx_L0:; 751 | __Pyx_XGIVEREF(__pyx_r); 752 | __Pyx_RefNannyFinishContext(); 753 | return __pyx_r; 754 | } 755 | 756 | /* "cityhash.pyx":76 757 | * return c_CityHash64(buf, len(buf)) 758 | * 759 | * cpdef CityHash64WithSeed(bytes buf, uint64 seed): # <<<<<<<<<<<<<< 760 | * """ 761 | * Description: Hash function for a byte array. For convenience, a 64-bit seed is also 762 | */ 763 | 764 | static PyObject *__pyx_pf_8cityhash_1CityHash64WithSeed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 765 | static char __pyx_doc_8cityhash_1CityHash64WithSeed[] = "\n Description: Hash function for a byte array. For convenience, a 64-bit seed is also\n hashed into the result.\n "; 766 | static PyObject *__pyx_pf_8cityhash_1CityHash64WithSeed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 767 | PyObject *__pyx_v_buf = 0; 768 | uint64 __pyx_v_seed; 769 | PyObject *__pyx_r = NULL; 770 | __Pyx_RefNannyDeclarations 771 | PyObject *__pyx_t_1 = NULL; 772 | int __pyx_lineno = 0; 773 | const char *__pyx_filename = NULL; 774 | int __pyx_clineno = 0; 775 | static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buf,&__pyx_n_s__seed,0}; 776 | __Pyx_RefNannySetupContext("CityHash64WithSeed"); 777 | __pyx_self = __pyx_self; 778 | { 779 | PyObject* values[2] = {0,0}; 780 | if (unlikely(__pyx_kwds)) { 781 | Py_ssize_t kw_args; 782 | switch (PyTuple_GET_SIZE(__pyx_args)) { 783 | case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 784 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 785 | case 0: break; 786 | default: goto __pyx_L5_argtuple_error; 787 | } 788 | kw_args = PyDict_Size(__pyx_kwds); 789 | switch (PyTuple_GET_SIZE(__pyx_args)) { 790 | case 0: 791 | values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buf); 792 | if (likely(values[0])) kw_args--; 793 | else goto __pyx_L5_argtuple_error; 794 | case 1: 795 | values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seed); 796 | if (likely(values[1])) kw_args--; 797 | else { 798 | __Pyx_RaiseArgtupleInvalid("CityHash64WithSeed", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 799 | } 800 | } 801 | if (unlikely(kw_args > 0)) { 802 | if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "CityHash64WithSeed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 803 | } 804 | } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { 805 | goto __pyx_L5_argtuple_error; 806 | } else { 807 | values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 808 | values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 809 | } 810 | __pyx_v_buf = ((PyObject*)values[0]); 811 | __pyx_v_seed = __Pyx_PyInt_from_py_uint64_t(values[1]); if (unlikely((__pyx_v_seed == (uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 812 | } 813 | goto __pyx_L4_argument_unpacking_done; 814 | __pyx_L5_argtuple_error:; 815 | __Pyx_RaiseArgtupleInvalid("CityHash64WithSeed", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 816 | __pyx_L3_error:; 817 | __Pyx_AddTraceback("cityhash.CityHash64WithSeed", __pyx_clineno, __pyx_lineno, __pyx_filename); 818 | __Pyx_RefNannyFinishContext(); 819 | return NULL; 820 | __pyx_L4_argument_unpacking_done:; 821 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buf), (&PyBytes_Type), 1, "buf", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 822 | __Pyx_XDECREF(__pyx_r); 823 | __pyx_t_1 = __pyx_f_8cityhash_CityHash64WithSeed(__pyx_v_buf, __pyx_v_seed, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 824 | __Pyx_GOTREF(__pyx_t_1); 825 | __pyx_r = __pyx_t_1; 826 | __pyx_t_1 = 0; 827 | goto __pyx_L0; 828 | 829 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 830 | goto __pyx_L0; 831 | __pyx_L1_error:; 832 | __Pyx_XDECREF(__pyx_t_1); 833 | __Pyx_AddTraceback("cityhash.CityHash64WithSeed", __pyx_clineno, __pyx_lineno, __pyx_filename); 834 | __pyx_r = NULL; 835 | __pyx_L0:; 836 | __Pyx_XGIVEREF(__pyx_r); 837 | __Pyx_RefNannyFinishContext(); 838 | return __pyx_r; 839 | } 840 | 841 | /* "cityhash.pyx":83 842 | * return c_CityHash64WithSeed(buf, len(buf), seed) 843 | * 844 | * cpdef CityHash64WithSeeds(bytes buf, uint64 seed0, uint64 seed1): # <<<<<<<<<<<<<< 845 | * """ 846 | * Description: Hash function for a byte array. For convenience, two seeds are also 847 | */ 848 | 849 | static PyObject *__pyx_pf_8cityhash_2CityHash64WithSeeds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 850 | static PyObject *__pyx_f_8cityhash_CityHash64WithSeeds(PyObject *__pyx_v_buf, uint64 __pyx_v_seed0, uint64 __pyx_v_seed1, int __pyx_skip_dispatch) { 851 | PyObject *__pyx_r = NULL; 852 | __Pyx_RefNannyDeclarations 853 | char *__pyx_t_1; 854 | Py_ssize_t __pyx_t_2; 855 | PyObject *__pyx_t_3 = NULL; 856 | int __pyx_lineno = 0; 857 | const char *__pyx_filename = NULL; 858 | int __pyx_clineno = 0; 859 | __Pyx_RefNannySetupContext("CityHash64WithSeeds"); 860 | 861 | /* "cityhash.pyx":88 862 | * hashed into the result. 863 | * """ 864 | * return c_CityHash64WithSeeds(buf, len(buf), seed0, seed1) # <<<<<<<<<<<<<< 865 | * 866 | * cpdef CityHash128(bytes buf): 867 | */ 868 | __Pyx_XDECREF(__pyx_r); 869 | __pyx_t_1 = PyBytes_AsString(((PyObject *)__pyx_v_buf)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 870 | if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { 871 | PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 872 | } 873 | __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_buf)); 874 | __pyx_t_3 = __Pyx_PyInt_to_py_uint64_t(CityHash64WithSeeds(__pyx_t_1, __pyx_t_2, __pyx_v_seed0, __pyx_v_seed1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 875 | __Pyx_GOTREF(__pyx_t_3); 876 | __pyx_r = __pyx_t_3; 877 | __pyx_t_3 = 0; 878 | goto __pyx_L0; 879 | 880 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 881 | goto __pyx_L0; 882 | __pyx_L1_error:; 883 | __Pyx_XDECREF(__pyx_t_3); 884 | __Pyx_AddTraceback("cityhash.CityHash64WithSeeds", __pyx_clineno, __pyx_lineno, __pyx_filename); 885 | __pyx_r = 0; 886 | __pyx_L0:; 887 | __Pyx_XGIVEREF(__pyx_r); 888 | __Pyx_RefNannyFinishContext(); 889 | return __pyx_r; 890 | } 891 | 892 | /* "cityhash.pyx":83 893 | * return c_CityHash64WithSeed(buf, len(buf), seed) 894 | * 895 | * cpdef CityHash64WithSeeds(bytes buf, uint64 seed0, uint64 seed1): # <<<<<<<<<<<<<< 896 | * """ 897 | * Description: Hash function for a byte array. For convenience, two seeds are also 898 | */ 899 | 900 | static PyObject *__pyx_pf_8cityhash_2CityHash64WithSeeds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 901 | static char __pyx_doc_8cityhash_2CityHash64WithSeeds[] = "\n Description: Hash function for a byte array. For convenience, two seeds are also\n hashed into the result.\n "; 902 | static PyObject *__pyx_pf_8cityhash_2CityHash64WithSeeds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 903 | PyObject *__pyx_v_buf = 0; 904 | uint64 __pyx_v_seed0; 905 | uint64 __pyx_v_seed1; 906 | PyObject *__pyx_r = NULL; 907 | __Pyx_RefNannyDeclarations 908 | PyObject *__pyx_t_1 = NULL; 909 | int __pyx_lineno = 0; 910 | const char *__pyx_filename = NULL; 911 | int __pyx_clineno = 0; 912 | static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buf,&__pyx_n_s__seed0,&__pyx_n_s__seed1,0}; 913 | __Pyx_RefNannySetupContext("CityHash64WithSeeds"); 914 | __pyx_self = __pyx_self; 915 | { 916 | PyObject* values[3] = {0,0,0}; 917 | if (unlikely(__pyx_kwds)) { 918 | Py_ssize_t kw_args; 919 | switch (PyTuple_GET_SIZE(__pyx_args)) { 920 | case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 921 | case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 922 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 923 | case 0: break; 924 | default: goto __pyx_L5_argtuple_error; 925 | } 926 | kw_args = PyDict_Size(__pyx_kwds); 927 | switch (PyTuple_GET_SIZE(__pyx_args)) { 928 | case 0: 929 | values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buf); 930 | if (likely(values[0])) kw_args--; 931 | else goto __pyx_L5_argtuple_error; 932 | case 1: 933 | values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seed0); 934 | if (likely(values[1])) kw_args--; 935 | else { 936 | __Pyx_RaiseArgtupleInvalid("CityHash64WithSeeds", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 937 | } 938 | case 2: 939 | values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seed1); 940 | if (likely(values[2])) kw_args--; 941 | else { 942 | __Pyx_RaiseArgtupleInvalid("CityHash64WithSeeds", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 943 | } 944 | } 945 | if (unlikely(kw_args > 0)) { 946 | if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "CityHash64WithSeeds") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 947 | } 948 | } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { 949 | goto __pyx_L5_argtuple_error; 950 | } else { 951 | values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 952 | values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 953 | values[2] = PyTuple_GET_ITEM(__pyx_args, 2); 954 | } 955 | __pyx_v_buf = ((PyObject*)values[0]); 956 | __pyx_v_seed0 = __Pyx_PyInt_from_py_uint64_t(values[1]); if (unlikely((__pyx_v_seed0 == (uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 957 | __pyx_v_seed1 = __Pyx_PyInt_from_py_uint64_t(values[2]); if (unlikely((__pyx_v_seed1 == (uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 958 | } 959 | goto __pyx_L4_argument_unpacking_done; 960 | __pyx_L5_argtuple_error:; 961 | __Pyx_RaiseArgtupleInvalid("CityHash64WithSeeds", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 962 | __pyx_L3_error:; 963 | __Pyx_AddTraceback("cityhash.CityHash64WithSeeds", __pyx_clineno, __pyx_lineno, __pyx_filename); 964 | __Pyx_RefNannyFinishContext(); 965 | return NULL; 966 | __pyx_L4_argument_unpacking_done:; 967 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buf), (&PyBytes_Type), 1, "buf", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 968 | __Pyx_XDECREF(__pyx_r); 969 | __pyx_t_1 = __pyx_f_8cityhash_CityHash64WithSeeds(__pyx_v_buf, __pyx_v_seed0, __pyx_v_seed1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 970 | __Pyx_GOTREF(__pyx_t_1); 971 | __pyx_r = __pyx_t_1; 972 | __pyx_t_1 = 0; 973 | goto __pyx_L0; 974 | 975 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 976 | goto __pyx_L0; 977 | __pyx_L1_error:; 978 | __Pyx_XDECREF(__pyx_t_1); 979 | __Pyx_AddTraceback("cityhash.CityHash64WithSeeds", __pyx_clineno, __pyx_lineno, __pyx_filename); 980 | __pyx_r = NULL; 981 | __pyx_L0:; 982 | __Pyx_XGIVEREF(__pyx_r); 983 | __Pyx_RefNannyFinishContext(); 984 | return __pyx_r; 985 | } 986 | 987 | /* "cityhash.pyx":90 988 | * return c_CityHash64WithSeeds(buf, len(buf), seed0, seed1) 989 | * 990 | * cpdef CityHash128(bytes buf): # <<<<<<<<<<<<<< 991 | * """ 992 | * Description: Hash function for a byte array. 993 | */ 994 | 995 | static PyObject *__pyx_pf_8cityhash_3CityHash128(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/ 996 | static PyObject *__pyx_f_8cityhash_CityHash128(PyObject *__pyx_v_buf, int __pyx_skip_dispatch) { 997 | std::pair __pyx_v_result; 998 | PyObject *__pyx_r = NULL; 999 | __Pyx_RefNannyDeclarations 1000 | char *__pyx_t_1; 1001 | Py_ssize_t __pyx_t_2; 1002 | PyObject *__pyx_t_3 = NULL; 1003 | PyObject *__pyx_t_4 = NULL; 1004 | PyObject *__pyx_t_5 = NULL; 1005 | int __pyx_lineno = 0; 1006 | const char *__pyx_filename = NULL; 1007 | int __pyx_clineno = 0; 1008 | __Pyx_RefNannySetupContext("CityHash128"); 1009 | 1010 | /* "cityhash.pyx":94 1011 | * Description: Hash function for a byte array. 1012 | * """ 1013 | * cdef pair[uint64,uint64] result = c_CityHash128(buf, len(buf)) # <<<<<<<<<<<<<< 1014 | * return (result.first, result.second) 1015 | * 1016 | */ 1017 | __pyx_t_1 = PyBytes_AsString(((PyObject *)__pyx_v_buf)); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1018 | if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { 1019 | PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1020 | } 1021 | __pyx_t_2 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_buf)); 1022 | __pyx_v_result = CityHash128(__pyx_t_1, __pyx_t_2); 1023 | 1024 | /* "cityhash.pyx":95 1025 | * """ 1026 | * cdef pair[uint64,uint64] result = c_CityHash128(buf, len(buf)) 1027 | * return (result.first, result.second) # <<<<<<<<<<<<<< 1028 | * 1029 | * cpdef CityHash128WithSeed(bytes buf, tuple seed): 1030 | */ 1031 | __Pyx_XDECREF(__pyx_r); 1032 | __pyx_t_3 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_result.first); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1033 | __Pyx_GOTREF(__pyx_t_3); 1034 | __pyx_t_4 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_result.second); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1035 | __Pyx_GOTREF(__pyx_t_4); 1036 | __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1037 | __Pyx_GOTREF(((PyObject *)__pyx_t_5)); 1038 | PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); 1039 | __Pyx_GIVEREF(__pyx_t_3); 1040 | PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); 1041 | __Pyx_GIVEREF(__pyx_t_4); 1042 | __pyx_t_3 = 0; 1043 | __pyx_t_4 = 0; 1044 | __pyx_r = ((PyObject *)__pyx_t_5); 1045 | __pyx_t_5 = 0; 1046 | goto __pyx_L0; 1047 | 1048 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1049 | goto __pyx_L0; 1050 | __pyx_L1_error:; 1051 | __Pyx_XDECREF(__pyx_t_3); 1052 | __Pyx_XDECREF(__pyx_t_4); 1053 | __Pyx_XDECREF(__pyx_t_5); 1054 | __Pyx_AddTraceback("cityhash.CityHash128", __pyx_clineno, __pyx_lineno, __pyx_filename); 1055 | __pyx_r = 0; 1056 | __pyx_L0:; 1057 | __Pyx_XGIVEREF(__pyx_r); 1058 | __Pyx_RefNannyFinishContext(); 1059 | return __pyx_r; 1060 | } 1061 | 1062 | /* "cityhash.pyx":90 1063 | * return c_CityHash64WithSeeds(buf, len(buf), seed0, seed1) 1064 | * 1065 | * cpdef CityHash128(bytes buf): # <<<<<<<<<<<<<< 1066 | * """ 1067 | * Description: Hash function for a byte array. 1068 | */ 1069 | 1070 | static PyObject *__pyx_pf_8cityhash_3CityHash128(PyObject *__pyx_self, PyObject *__pyx_v_buf); /*proto*/ 1071 | static char __pyx_doc_8cityhash_3CityHash128[] = "\n Description: Hash function for a byte array.\n "; 1072 | static PyObject *__pyx_pf_8cityhash_3CityHash128(PyObject *__pyx_self, PyObject *__pyx_v_buf) { 1073 | PyObject *__pyx_r = NULL; 1074 | __Pyx_RefNannyDeclarations 1075 | PyObject *__pyx_t_1 = NULL; 1076 | int __pyx_lineno = 0; 1077 | const char *__pyx_filename = NULL; 1078 | int __pyx_clineno = 0; 1079 | __Pyx_RefNannySetupContext("CityHash128"); 1080 | __pyx_self = __pyx_self; 1081 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buf), (&PyBytes_Type), 1, "buf", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1082 | __Pyx_XDECREF(__pyx_r); 1083 | __pyx_t_1 = __pyx_f_8cityhash_CityHash128(__pyx_v_buf, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1084 | __Pyx_GOTREF(__pyx_t_1); 1085 | __pyx_r = __pyx_t_1; 1086 | __pyx_t_1 = 0; 1087 | goto __pyx_L0; 1088 | 1089 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1090 | goto __pyx_L0; 1091 | __pyx_L1_error:; 1092 | __Pyx_XDECREF(__pyx_t_1); 1093 | __Pyx_AddTraceback("cityhash.CityHash128", __pyx_clineno, __pyx_lineno, __pyx_filename); 1094 | __pyx_r = NULL; 1095 | __pyx_L0:; 1096 | __Pyx_XGIVEREF(__pyx_r); 1097 | __Pyx_RefNannyFinishContext(); 1098 | return __pyx_r; 1099 | } 1100 | 1101 | /* "cityhash.pyx":97 1102 | * return (result.first, result.second) 1103 | * 1104 | * cpdef CityHash128WithSeed(bytes buf, tuple seed): # <<<<<<<<<<<<<< 1105 | * """ 1106 | * Description: Hash function for a byte array. For convenience, a 128-bit seed is also 1107 | */ 1108 | 1109 | static PyObject *__pyx_pf_8cityhash_4CityHash128WithSeed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1110 | static PyObject *__pyx_f_8cityhash_CityHash128WithSeed(PyObject *__pyx_v_buf, PyObject *__pyx_v_seed, int __pyx_skip_dispatch) { 1111 | std::pair __pyx_v_tseed; 1112 | std::pair __pyx_v_result; 1113 | PyObject *__pyx_r = NULL; 1114 | __Pyx_RefNannyDeclarations 1115 | PyObject *__pyx_t_1 = NULL; 1116 | uint64 __pyx_t_2; 1117 | uint64 __pyx_t_3; 1118 | char *__pyx_t_4; 1119 | Py_ssize_t __pyx_t_5; 1120 | PyObject *__pyx_t_6 = NULL; 1121 | PyObject *__pyx_t_7 = NULL; 1122 | int __pyx_lineno = 0; 1123 | const char *__pyx_filename = NULL; 1124 | int __pyx_clineno = 0; 1125 | __Pyx_RefNannySetupContext("CityHash128WithSeed"); 1126 | 1127 | /* "cityhash.pyx":103 1128 | * """ 1129 | * cdef pair[uint64,uint64] tseed 1130 | * tseed.first, tseed.second = seed[0], seed[1] # <<<<<<<<<<<<<< 1131 | * cdef pair[uint64,uint64] result = c_CityHash128WithSeed(buf, len(buf), tseed) 1132 | * return (result.first, result.second) 1133 | */ 1134 | __pyx_t_1 = __Pyx_GetItemInt_Tuple(((PyObject *)__pyx_v_seed), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1135 | __Pyx_GOTREF(__pyx_t_1); 1136 | __pyx_t_2 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1137 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1138 | __pyx_t_1 = __Pyx_GetItemInt_Tuple(((PyObject *)__pyx_v_seed), 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1139 | __Pyx_GOTREF(__pyx_t_1); 1140 | __pyx_t_3 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1141 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1142 | __pyx_v_tseed.first = __pyx_t_2; 1143 | __pyx_v_tseed.second = __pyx_t_3; 1144 | 1145 | /* "cityhash.pyx":104 1146 | * cdef pair[uint64,uint64] tseed 1147 | * tseed.first, tseed.second = seed[0], seed[1] 1148 | * cdef pair[uint64,uint64] result = c_CityHash128WithSeed(buf, len(buf), tseed) # <<<<<<<<<<<<<< 1149 | * return (result.first, result.second) 1150 | * 1151 | */ 1152 | __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_buf)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1153 | if (unlikely(((PyObject *)__pyx_v_buf) == Py_None)) { 1154 | PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1155 | } 1156 | __pyx_t_5 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_buf)); 1157 | __pyx_v_result = CityHash128WithSeed(__pyx_t_4, __pyx_t_5, __pyx_v_tseed); 1158 | 1159 | /* "cityhash.pyx":105 1160 | * tseed.first, tseed.second = seed[0], seed[1] 1161 | * cdef pair[uint64,uint64] result = c_CityHash128WithSeed(buf, len(buf), tseed) 1162 | * return (result.first, result.second) # <<<<<<<<<<<<<< 1163 | * 1164 | * cpdef Hash128to64(tuple x): 1165 | */ 1166 | __Pyx_XDECREF(__pyx_r); 1167 | __pyx_t_1 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_result.first); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1168 | __Pyx_GOTREF(__pyx_t_1); 1169 | __pyx_t_6 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_result.second); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1170 | __Pyx_GOTREF(__pyx_t_6); 1171 | __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1172 | __Pyx_GOTREF(((PyObject *)__pyx_t_7)); 1173 | PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); 1174 | __Pyx_GIVEREF(__pyx_t_1); 1175 | PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); 1176 | __Pyx_GIVEREF(__pyx_t_6); 1177 | __pyx_t_1 = 0; 1178 | __pyx_t_6 = 0; 1179 | __pyx_r = ((PyObject *)__pyx_t_7); 1180 | __pyx_t_7 = 0; 1181 | goto __pyx_L0; 1182 | 1183 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1184 | goto __pyx_L0; 1185 | __pyx_L1_error:; 1186 | __Pyx_XDECREF(__pyx_t_1); 1187 | __Pyx_XDECREF(__pyx_t_6); 1188 | __Pyx_XDECREF(__pyx_t_7); 1189 | __Pyx_AddTraceback("cityhash.CityHash128WithSeed", __pyx_clineno, __pyx_lineno, __pyx_filename); 1190 | __pyx_r = 0; 1191 | __pyx_L0:; 1192 | __Pyx_XGIVEREF(__pyx_r); 1193 | __Pyx_RefNannyFinishContext(); 1194 | return __pyx_r; 1195 | } 1196 | 1197 | /* "cityhash.pyx":97 1198 | * return (result.first, result.second) 1199 | * 1200 | * cpdef CityHash128WithSeed(bytes buf, tuple seed): # <<<<<<<<<<<<<< 1201 | * """ 1202 | * Description: Hash function for a byte array. For convenience, a 128-bit seed is also 1203 | */ 1204 | 1205 | static PyObject *__pyx_pf_8cityhash_4CityHash128WithSeed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1206 | static char __pyx_doc_8cityhash_4CityHash128WithSeed[] = "\n Description: Hash function for a byte array. For convenience, a 128-bit seed is also\n hashed into the result.\n "; 1207 | static PyObject *__pyx_pf_8cityhash_4CityHash128WithSeed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 1208 | PyObject *__pyx_v_buf = 0; 1209 | PyObject *__pyx_v_seed = 0; 1210 | PyObject *__pyx_r = NULL; 1211 | __Pyx_RefNannyDeclarations 1212 | PyObject *__pyx_t_1 = NULL; 1213 | int __pyx_lineno = 0; 1214 | const char *__pyx_filename = NULL; 1215 | int __pyx_clineno = 0; 1216 | static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buf,&__pyx_n_s__seed,0}; 1217 | __Pyx_RefNannySetupContext("CityHash128WithSeed"); 1218 | __pyx_self = __pyx_self; 1219 | { 1220 | PyObject* values[2] = {0,0}; 1221 | if (unlikely(__pyx_kwds)) { 1222 | Py_ssize_t kw_args; 1223 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1224 | case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 1225 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1226 | case 0: break; 1227 | default: goto __pyx_L5_argtuple_error; 1228 | } 1229 | kw_args = PyDict_Size(__pyx_kwds); 1230 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1231 | case 0: 1232 | values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buf); 1233 | if (likely(values[0])) kw_args--; 1234 | else goto __pyx_L5_argtuple_error; 1235 | case 1: 1236 | values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seed); 1237 | if (likely(values[1])) kw_args--; 1238 | else { 1239 | __Pyx_RaiseArgtupleInvalid("CityHash128WithSeed", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1240 | } 1241 | } 1242 | if (unlikely(kw_args > 0)) { 1243 | if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "CityHash128WithSeed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1244 | } 1245 | } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { 1246 | goto __pyx_L5_argtuple_error; 1247 | } else { 1248 | values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1249 | values[1] = PyTuple_GET_ITEM(__pyx_args, 1); 1250 | } 1251 | __pyx_v_buf = ((PyObject*)values[0]); 1252 | __pyx_v_seed = ((PyObject*)values[1]); 1253 | } 1254 | goto __pyx_L4_argument_unpacking_done; 1255 | __pyx_L5_argtuple_error:; 1256 | __Pyx_RaiseArgtupleInvalid("CityHash128WithSeed", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1257 | __pyx_L3_error:; 1258 | __Pyx_AddTraceback("cityhash.CityHash128WithSeed", __pyx_clineno, __pyx_lineno, __pyx_filename); 1259 | __Pyx_RefNannyFinishContext(); 1260 | return NULL; 1261 | __pyx_L4_argument_unpacking_done:; 1262 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buf), (&PyBytes_Type), 1, "buf", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1263 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_seed), (&PyTuple_Type), 1, "seed", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1264 | __Pyx_XDECREF(__pyx_r); 1265 | __pyx_t_1 = __pyx_f_8cityhash_CityHash128WithSeed(__pyx_v_buf, __pyx_v_seed, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1266 | __Pyx_GOTREF(__pyx_t_1); 1267 | __pyx_r = __pyx_t_1; 1268 | __pyx_t_1 = 0; 1269 | goto __pyx_L0; 1270 | 1271 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1272 | goto __pyx_L0; 1273 | __pyx_L1_error:; 1274 | __Pyx_XDECREF(__pyx_t_1); 1275 | __Pyx_AddTraceback("cityhash.CityHash128WithSeed", __pyx_clineno, __pyx_lineno, __pyx_filename); 1276 | __pyx_r = NULL; 1277 | __pyx_L0:; 1278 | __Pyx_XGIVEREF(__pyx_r); 1279 | __Pyx_RefNannyFinishContext(); 1280 | return __pyx_r; 1281 | } 1282 | 1283 | /* "cityhash.pyx":107 1284 | * return (result.first, result.second) 1285 | * 1286 | * cpdef Hash128to64(tuple x): # <<<<<<<<<<<<<< 1287 | * """ 1288 | * Description: Hash 128 input bits down to 64 bits of output. 1289 | */ 1290 | 1291 | static PyObject *__pyx_pf_8cityhash_5Hash128to64(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ 1292 | static PyObject *__pyx_f_8cityhash_Hash128to64(PyObject *__pyx_v_x, int __pyx_skip_dispatch) { 1293 | std::pair __pyx_v_xx; 1294 | PyObject *__pyx_r = NULL; 1295 | __Pyx_RefNannyDeclarations 1296 | PyObject *__pyx_t_1 = NULL; 1297 | uint64 __pyx_t_2; 1298 | uint64 __pyx_t_3; 1299 | int __pyx_lineno = 0; 1300 | const char *__pyx_filename = NULL; 1301 | int __pyx_clineno = 0; 1302 | __Pyx_RefNannySetupContext("Hash128to64"); 1303 | 1304 | /* "cityhash.pyx":113 1305 | * """ 1306 | * cdef pair[uint64,uint64] xx 1307 | * xx.first, xx.second = x[0], x[1] # <<<<<<<<<<<<<< 1308 | * return c_Hash128to64(xx) 1309 | * 1310 | */ 1311 | __pyx_t_1 = __Pyx_GetItemInt_Tuple(((PyObject *)__pyx_v_x), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1312 | __Pyx_GOTREF(__pyx_t_1); 1313 | __pyx_t_2 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1314 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1315 | __pyx_t_1 = __Pyx_GetItemInt_Tuple(((PyObject *)__pyx_v_x), 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1316 | __Pyx_GOTREF(__pyx_t_1); 1317 | __pyx_t_3 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1318 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1319 | __pyx_v_xx.first = __pyx_t_2; 1320 | __pyx_v_xx.second = __pyx_t_3; 1321 | 1322 | /* "cityhash.pyx":114 1323 | * cdef pair[uint64,uint64] xx 1324 | * xx.first, xx.second = x[0], x[1] 1325 | * return c_Hash128to64(xx) # <<<<<<<<<<<<<< 1326 | * 1327 | * cdef class ch64: 1328 | */ 1329 | __Pyx_XDECREF(__pyx_r); 1330 | __pyx_t_1 = __Pyx_PyInt_to_py_uint64_t(Hash128to64(__pyx_v_xx)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1331 | __Pyx_GOTREF(__pyx_t_1); 1332 | __pyx_r = __pyx_t_1; 1333 | __pyx_t_1 = 0; 1334 | goto __pyx_L0; 1335 | 1336 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1337 | goto __pyx_L0; 1338 | __pyx_L1_error:; 1339 | __Pyx_XDECREF(__pyx_t_1); 1340 | __Pyx_AddTraceback("cityhash.Hash128to64", __pyx_clineno, __pyx_lineno, __pyx_filename); 1341 | __pyx_r = 0; 1342 | __pyx_L0:; 1343 | __Pyx_XGIVEREF(__pyx_r); 1344 | __Pyx_RefNannyFinishContext(); 1345 | return __pyx_r; 1346 | } 1347 | 1348 | /* "cityhash.pyx":107 1349 | * return (result.first, result.second) 1350 | * 1351 | * cpdef Hash128to64(tuple x): # <<<<<<<<<<<<<< 1352 | * """ 1353 | * Description: Hash 128 input bits down to 64 bits of output. 1354 | */ 1355 | 1356 | static PyObject *__pyx_pf_8cityhash_5Hash128to64(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/ 1357 | static char __pyx_doc_8cityhash_5Hash128to64[] = "\n Description: Hash 128 input bits down to 64 bits of output.\n This is intended to be a reasonably good hash function.\n "; 1358 | static PyObject *__pyx_pf_8cityhash_5Hash128to64(PyObject *__pyx_self, PyObject *__pyx_v_x) { 1359 | PyObject *__pyx_r = NULL; 1360 | __Pyx_RefNannyDeclarations 1361 | PyObject *__pyx_t_1 = NULL; 1362 | int __pyx_lineno = 0; 1363 | const char *__pyx_filename = NULL; 1364 | int __pyx_clineno = 0; 1365 | __Pyx_RefNannySetupContext("Hash128to64"); 1366 | __pyx_self = __pyx_self; 1367 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), (&PyTuple_Type), 1, "x", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1368 | __Pyx_XDECREF(__pyx_r); 1369 | __pyx_t_1 = __pyx_f_8cityhash_Hash128to64(__pyx_v_x, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1370 | __Pyx_GOTREF(__pyx_t_1); 1371 | __pyx_r = __pyx_t_1; 1372 | __pyx_t_1 = 0; 1373 | goto __pyx_L0; 1374 | 1375 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1376 | goto __pyx_L0; 1377 | __pyx_L1_error:; 1378 | __Pyx_XDECREF(__pyx_t_1); 1379 | __Pyx_AddTraceback("cityhash.Hash128to64", __pyx_clineno, __pyx_lineno, __pyx_filename); 1380 | __pyx_r = NULL; 1381 | __pyx_L0:; 1382 | __Pyx_XGIVEREF(__pyx_r); 1383 | __Pyx_RefNannyFinishContext(); 1384 | return __pyx_r; 1385 | } 1386 | 1387 | /* "cityhash.pyx":119 1388 | * cdef uint64 __value 1389 | * cdef public bytes name 1390 | * def __cinit__(self, bytes value=str("")): # <<<<<<<<<<<<<< 1391 | * self.name = str("CityHash64") 1392 | * self.update(value) 1393 | */ 1394 | 1395 | static int __pyx_pf_8cityhash_4ch64___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1396 | static int __pyx_pf_8cityhash_4ch64___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 1397 | PyObject *__pyx_v_value = 0; 1398 | int __pyx_r; 1399 | __Pyx_RefNannyDeclarations 1400 | PyObject *__pyx_t_1 = NULL; 1401 | int __pyx_lineno = 0; 1402 | const char *__pyx_filename = NULL; 1403 | int __pyx_clineno = 0; 1404 | static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__value,0}; 1405 | __Pyx_RefNannySetupContext("__cinit__"); 1406 | { 1407 | PyObject* values[1] = {0}; 1408 | values[0] = __pyx_k_1; 1409 | if (unlikely(__pyx_kwds)) { 1410 | Py_ssize_t kw_args; 1411 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1412 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1413 | case 0: break; 1414 | default: goto __pyx_L5_argtuple_error; 1415 | } 1416 | kw_args = PyDict_Size(__pyx_kwds); 1417 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1418 | case 0: 1419 | if (kw_args > 0) { 1420 | PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value); 1421 | if (value) { values[0] = value; kw_args--; } 1422 | } 1423 | } 1424 | if (unlikely(kw_args > 0)) { 1425 | if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1426 | } 1427 | } else { 1428 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1429 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1430 | case 0: break; 1431 | default: goto __pyx_L5_argtuple_error; 1432 | } 1433 | } 1434 | __pyx_v_value = ((PyObject*)values[0]); 1435 | } 1436 | goto __pyx_L4_argument_unpacking_done; 1437 | __pyx_L5_argtuple_error:; 1438 | __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1439 | __pyx_L3_error:; 1440 | __Pyx_AddTraceback("cityhash.ch64.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); 1441 | __Pyx_RefNannyFinishContext(); 1442 | return -1; 1443 | __pyx_L4_argument_unpacking_done:; 1444 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyBytes_Type), 1, "value", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1445 | 1446 | /* "cityhash.pyx":120 1447 | * cdef public bytes name 1448 | * def __cinit__(self, bytes value=str("")): 1449 | * self.name = str("CityHash64") # <<<<<<<<<<<<<< 1450 | * self.update(value) 1451 | * cpdef update(self, bytes value): 1452 | */ 1453 | __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1454 | __Pyx_GOTREF(__pyx_t_1); 1455 | if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1456 | __Pyx_GIVEREF(__pyx_t_1); 1457 | __Pyx_GOTREF(((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name); 1458 | __Pyx_DECREF(((PyObject *)((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name)); 1459 | ((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name = ((PyObject*)__pyx_t_1); 1460 | __pyx_t_1 = 0; 1461 | 1462 | /* "cityhash.pyx":121 1463 | * def __cinit__(self, bytes value=str("")): 1464 | * self.name = str("CityHash64") 1465 | * self.update(value) # <<<<<<<<<<<<<< 1466 | * cpdef update(self, bytes value): 1467 | * if self.__value: 1468 | */ 1469 | __pyx_t_1 = ((struct __pyx_vtabstruct_8cityhash_ch64 *)((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->__pyx_vtab)->update(((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self), __pyx_v_value, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1470 | __Pyx_GOTREF(__pyx_t_1); 1471 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1472 | 1473 | __pyx_r = 0; 1474 | goto __pyx_L0; 1475 | __pyx_L1_error:; 1476 | __Pyx_XDECREF(__pyx_t_1); 1477 | __Pyx_AddTraceback("cityhash.ch64.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); 1478 | __pyx_r = -1; 1479 | __pyx_L0:; 1480 | __Pyx_RefNannyFinishContext(); 1481 | return __pyx_r; 1482 | } 1483 | 1484 | /* "cityhash.pyx":122 1485 | * self.name = str("CityHash64") 1486 | * self.update(value) 1487 | * cpdef update(self, bytes value): # <<<<<<<<<<<<<< 1488 | * if self.__value: 1489 | * self.__value = c_CityHash64WithSeed(value, len(value), self.__value) 1490 | */ 1491 | 1492 | static PyObject *__pyx_pf_8cityhash_4ch64_1update(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ 1493 | static PyObject *__pyx_f_8cityhash_4ch64_update(struct __pyx_obj_8cityhash_ch64 *__pyx_v_self, PyObject *__pyx_v_value, int __pyx_skip_dispatch) { 1494 | PyObject *__pyx_r = NULL; 1495 | __Pyx_RefNannyDeclarations 1496 | PyObject *__pyx_t_1 = NULL; 1497 | PyObject *__pyx_t_2 = NULL; 1498 | PyObject *__pyx_t_3 = NULL; 1499 | char *__pyx_t_4; 1500 | Py_ssize_t __pyx_t_5; 1501 | int __pyx_lineno = 0; 1502 | const char *__pyx_filename = NULL; 1503 | int __pyx_clineno = 0; 1504 | __Pyx_RefNannySetupContext("update"); 1505 | /* Check if called by wrapper */ 1506 | if (unlikely(__pyx_skip_dispatch)) ; 1507 | /* Check if overriden in Python */ 1508 | else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { 1509 | __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1510 | __Pyx_GOTREF(__pyx_t_1); 1511 | if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_8cityhash_4ch64_1update)) { 1512 | __Pyx_XDECREF(__pyx_r); 1513 | __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1514 | __Pyx_GOTREF(((PyObject *)__pyx_t_2)); 1515 | __Pyx_INCREF(((PyObject *)__pyx_v_value)); 1516 | PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_value)); 1517 | __Pyx_GIVEREF(((PyObject *)__pyx_v_value)); 1518 | __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1519 | __Pyx_GOTREF(__pyx_t_3); 1520 | __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; 1521 | __pyx_r = __pyx_t_3; 1522 | __pyx_t_3 = 0; 1523 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1524 | goto __pyx_L0; 1525 | } 1526 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1527 | } 1528 | 1529 | /* "cityhash.pyx":123 1530 | * self.update(value) 1531 | * cpdef update(self, bytes value): 1532 | * if self.__value: # <<<<<<<<<<<<<< 1533 | * self.__value = c_CityHash64WithSeed(value, len(value), self.__value) 1534 | * else: 1535 | */ 1536 | if (__pyx_v_self->__pyx___value) { 1537 | 1538 | /* "cityhash.pyx":124 1539 | * cpdef update(self, bytes value): 1540 | * if self.__value: 1541 | * self.__value = c_CityHash64WithSeed(value, len(value), self.__value) # <<<<<<<<<<<<<< 1542 | * else: 1543 | * self.__value = c_CityHash64(value, len(value)) 1544 | */ 1545 | __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_value)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1546 | if (unlikely(((PyObject *)__pyx_v_value) == Py_None)) { 1547 | PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1548 | } 1549 | __pyx_t_5 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_value)); 1550 | __pyx_v_self->__pyx___value = CityHash64WithSeed(__pyx_t_4, __pyx_t_5, __pyx_v_self->__pyx___value); 1551 | goto __pyx_L3; 1552 | } 1553 | /*else*/ { 1554 | 1555 | /* "cityhash.pyx":126 1556 | * self.__value = c_CityHash64WithSeed(value, len(value), self.__value) 1557 | * else: 1558 | * self.__value = c_CityHash64(value, len(value)) # <<<<<<<<<<<<<< 1559 | * cpdef digest(self): 1560 | * return self.__value 1561 | */ 1562 | __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_value)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1563 | if (unlikely(((PyObject *)__pyx_v_value) == Py_None)) { 1564 | PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1565 | } 1566 | __pyx_t_5 = PyBytes_GET_SIZE(((PyObject *)__pyx_v_value)); 1567 | __pyx_v_self->__pyx___value = CityHash64(__pyx_t_4, __pyx_t_5); 1568 | } 1569 | __pyx_L3:; 1570 | 1571 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1572 | goto __pyx_L0; 1573 | __pyx_L1_error:; 1574 | __Pyx_XDECREF(__pyx_t_1); 1575 | __Pyx_XDECREF(__pyx_t_2); 1576 | __Pyx_XDECREF(__pyx_t_3); 1577 | __Pyx_AddTraceback("cityhash.ch64.update", __pyx_clineno, __pyx_lineno, __pyx_filename); 1578 | __pyx_r = 0; 1579 | __pyx_L0:; 1580 | __Pyx_XGIVEREF(__pyx_r); 1581 | __Pyx_RefNannyFinishContext(); 1582 | return __pyx_r; 1583 | } 1584 | 1585 | /* "cityhash.pyx":122 1586 | * self.name = str("CityHash64") 1587 | * self.update(value) 1588 | * cpdef update(self, bytes value): # <<<<<<<<<<<<<< 1589 | * if self.__value: 1590 | * self.__value = c_CityHash64WithSeed(value, len(value), self.__value) 1591 | */ 1592 | 1593 | static PyObject *__pyx_pf_8cityhash_4ch64_1update(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ 1594 | static PyObject *__pyx_pf_8cityhash_4ch64_1update(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { 1595 | PyObject *__pyx_r = NULL; 1596 | __Pyx_RefNannyDeclarations 1597 | PyObject *__pyx_t_1 = NULL; 1598 | int __pyx_lineno = 0; 1599 | const char *__pyx_filename = NULL; 1600 | int __pyx_clineno = 0; 1601 | __Pyx_RefNannySetupContext("update"); 1602 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyBytes_Type), 1, "value", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1603 | __Pyx_XDECREF(__pyx_r); 1604 | __pyx_t_1 = ((struct __pyx_vtabstruct_8cityhash_ch64 *)((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->__pyx_vtab)->update(((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self), __pyx_v_value, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1605 | __Pyx_GOTREF(__pyx_t_1); 1606 | __pyx_r = __pyx_t_1; 1607 | __pyx_t_1 = 0; 1608 | goto __pyx_L0; 1609 | 1610 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1611 | goto __pyx_L0; 1612 | __pyx_L1_error:; 1613 | __Pyx_XDECREF(__pyx_t_1); 1614 | __Pyx_AddTraceback("cityhash.ch64.update", __pyx_clineno, __pyx_lineno, __pyx_filename); 1615 | __pyx_r = NULL; 1616 | __pyx_L0:; 1617 | __Pyx_XGIVEREF(__pyx_r); 1618 | __Pyx_RefNannyFinishContext(); 1619 | return __pyx_r; 1620 | } 1621 | 1622 | /* "cityhash.pyx":127 1623 | * else: 1624 | * self.__value = c_CityHash64(value, len(value)) 1625 | * cpdef digest(self): # <<<<<<<<<<<<<< 1626 | * return self.__value 1627 | * 1628 | */ 1629 | 1630 | static PyObject *__pyx_pf_8cityhash_4ch64_2digest(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ 1631 | static PyObject *__pyx_f_8cityhash_4ch64_digest(struct __pyx_obj_8cityhash_ch64 *__pyx_v_self, int __pyx_skip_dispatch) { 1632 | PyObject *__pyx_r = NULL; 1633 | __Pyx_RefNannyDeclarations 1634 | PyObject *__pyx_t_1 = NULL; 1635 | PyObject *__pyx_t_2 = NULL; 1636 | int __pyx_lineno = 0; 1637 | const char *__pyx_filename = NULL; 1638 | int __pyx_clineno = 0; 1639 | __Pyx_RefNannySetupContext("digest"); 1640 | /* Check if called by wrapper */ 1641 | if (unlikely(__pyx_skip_dispatch)) ; 1642 | /* Check if overriden in Python */ 1643 | else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { 1644 | __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__digest); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1645 | __Pyx_GOTREF(__pyx_t_1); 1646 | if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_8cityhash_4ch64_2digest)) { 1647 | __Pyx_XDECREF(__pyx_r); 1648 | __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1649 | __Pyx_GOTREF(__pyx_t_2); 1650 | __pyx_r = __pyx_t_2; 1651 | __pyx_t_2 = 0; 1652 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1653 | goto __pyx_L0; 1654 | } 1655 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1656 | } 1657 | 1658 | /* "cityhash.pyx":128 1659 | * self.__value = c_CityHash64(value, len(value)) 1660 | * cpdef digest(self): 1661 | * return self.__value # <<<<<<<<<<<<<< 1662 | * 1663 | * cdef class ch128: 1664 | */ 1665 | __Pyx_XDECREF(__pyx_r); 1666 | __pyx_t_1 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_self->__pyx___value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1667 | __Pyx_GOTREF(__pyx_t_1); 1668 | __pyx_r = __pyx_t_1; 1669 | __pyx_t_1 = 0; 1670 | goto __pyx_L0; 1671 | 1672 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1673 | goto __pyx_L0; 1674 | __pyx_L1_error:; 1675 | __Pyx_XDECREF(__pyx_t_1); 1676 | __Pyx_XDECREF(__pyx_t_2); 1677 | __Pyx_AddTraceback("cityhash.ch64.digest", __pyx_clineno, __pyx_lineno, __pyx_filename); 1678 | __pyx_r = 0; 1679 | __pyx_L0:; 1680 | __Pyx_XGIVEREF(__pyx_r); 1681 | __Pyx_RefNannyFinishContext(); 1682 | return __pyx_r; 1683 | } 1684 | 1685 | /* "cityhash.pyx":127 1686 | * else: 1687 | * self.__value = c_CityHash64(value, len(value)) 1688 | * cpdef digest(self): # <<<<<<<<<<<<<< 1689 | * return self.__value 1690 | * 1691 | */ 1692 | 1693 | static PyObject *__pyx_pf_8cityhash_4ch64_2digest(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ 1694 | static PyObject *__pyx_pf_8cityhash_4ch64_2digest(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { 1695 | PyObject *__pyx_r = NULL; 1696 | __Pyx_RefNannyDeclarations 1697 | PyObject *__pyx_t_1 = NULL; 1698 | int __pyx_lineno = 0; 1699 | const char *__pyx_filename = NULL; 1700 | int __pyx_clineno = 0; 1701 | __Pyx_RefNannySetupContext("digest"); 1702 | __Pyx_XDECREF(__pyx_r); 1703 | __pyx_t_1 = ((struct __pyx_vtabstruct_8cityhash_ch64 *)((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->__pyx_vtab)->digest(((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1704 | __Pyx_GOTREF(__pyx_t_1); 1705 | __pyx_r = __pyx_t_1; 1706 | __pyx_t_1 = 0; 1707 | goto __pyx_L0; 1708 | 1709 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1710 | goto __pyx_L0; 1711 | __pyx_L1_error:; 1712 | __Pyx_XDECREF(__pyx_t_1); 1713 | __Pyx_AddTraceback("cityhash.ch64.digest", __pyx_clineno, __pyx_lineno, __pyx_filename); 1714 | __pyx_r = NULL; 1715 | __pyx_L0:; 1716 | __Pyx_XGIVEREF(__pyx_r); 1717 | __Pyx_RefNannyFinishContext(); 1718 | return __pyx_r; 1719 | } 1720 | 1721 | /* "cityhash.pyx":118 1722 | * cdef class ch64: 1723 | * cdef uint64 __value 1724 | * cdef public bytes name # <<<<<<<<<<<<<< 1725 | * def __cinit__(self, bytes value=str("")): 1726 | * self.name = str("CityHash64") 1727 | */ 1728 | 1729 | static PyObject *__pyx_pf_8cityhash_4ch64_4name___get__(PyObject *__pyx_v_self); /*proto*/ 1730 | static PyObject *__pyx_pf_8cityhash_4ch64_4name___get__(PyObject *__pyx_v_self) { 1731 | PyObject *__pyx_r = NULL; 1732 | __Pyx_RefNannyDeclarations 1733 | __Pyx_RefNannySetupContext("__get__"); 1734 | __Pyx_XDECREF(__pyx_r); 1735 | __Pyx_INCREF(((PyObject *)((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name)); 1736 | __pyx_r = ((PyObject *)((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name); 1737 | goto __pyx_L0; 1738 | 1739 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1740 | __pyx_L0:; 1741 | __Pyx_XGIVEREF(__pyx_r); 1742 | __Pyx_RefNannyFinishContext(); 1743 | return __pyx_r; 1744 | } 1745 | 1746 | static int __pyx_pf_8cityhash_4ch64_4name_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ 1747 | static int __pyx_pf_8cityhash_4ch64_4name_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { 1748 | int __pyx_r; 1749 | __Pyx_RefNannyDeclarations 1750 | int __pyx_lineno = 0; 1751 | const char *__pyx_filename = NULL; 1752 | int __pyx_clineno = 0; 1753 | __Pyx_RefNannySetupContext("__set__"); 1754 | if (!(likely(PyBytes_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1755 | __Pyx_INCREF(__pyx_v_value); 1756 | __Pyx_GIVEREF(__pyx_v_value); 1757 | __Pyx_GOTREF(((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name); 1758 | __Pyx_DECREF(((PyObject *)((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name)); 1759 | ((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name = ((PyObject*)__pyx_v_value); 1760 | 1761 | __pyx_r = 0; 1762 | goto __pyx_L0; 1763 | __pyx_L1_error:; 1764 | __Pyx_AddTraceback("cityhash.ch64.name.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); 1765 | __pyx_r = -1; 1766 | __pyx_L0:; 1767 | __Pyx_RefNannyFinishContext(); 1768 | return __pyx_r; 1769 | } 1770 | 1771 | static int __pyx_pf_8cityhash_4ch64_4name_2__del__(PyObject *__pyx_v_self); /*proto*/ 1772 | static int __pyx_pf_8cityhash_4ch64_4name_2__del__(PyObject *__pyx_v_self) { 1773 | int __pyx_r; 1774 | __Pyx_RefNannyDeclarations 1775 | __Pyx_RefNannySetupContext("__del__"); 1776 | __Pyx_INCREF(Py_None); 1777 | __Pyx_GIVEREF(Py_None); 1778 | __Pyx_GOTREF(((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name); 1779 | __Pyx_DECREF(((PyObject *)((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name)); 1780 | ((struct __pyx_obj_8cityhash_ch64 *)__pyx_v_self)->name = ((PyObject*)Py_None); 1781 | 1782 | __pyx_r = 0; 1783 | __Pyx_RefNannyFinishContext(); 1784 | return __pyx_r; 1785 | } 1786 | 1787 | /* "cityhash.pyx":133 1788 | * cdef tuple __value 1789 | * cdef public bytes name 1790 | * def __cinit__(self, bytes value=str("")): # <<<<<<<<<<<<<< 1791 | * self.name = str("CityHash128") 1792 | * self.update(value) 1793 | */ 1794 | 1795 | static int __pyx_pf_8cityhash_5ch128___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 1796 | static int __pyx_pf_8cityhash_5ch128___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 1797 | PyObject *__pyx_v_value = 0; 1798 | int __pyx_r; 1799 | __Pyx_RefNannyDeclarations 1800 | PyObject *__pyx_t_1 = NULL; 1801 | int __pyx_lineno = 0; 1802 | const char *__pyx_filename = NULL; 1803 | int __pyx_clineno = 0; 1804 | static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__value,0}; 1805 | __Pyx_RefNannySetupContext("__cinit__"); 1806 | { 1807 | PyObject* values[1] = {0}; 1808 | values[0] = __pyx_k_3; 1809 | if (unlikely(__pyx_kwds)) { 1810 | Py_ssize_t kw_args; 1811 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1812 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1813 | case 0: break; 1814 | default: goto __pyx_L5_argtuple_error; 1815 | } 1816 | kw_args = PyDict_Size(__pyx_kwds); 1817 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1818 | case 0: 1819 | if (kw_args > 0) { 1820 | PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value); 1821 | if (value) { values[0] = value; kw_args--; } 1822 | } 1823 | } 1824 | if (unlikely(kw_args > 0)) { 1825 | if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1826 | } 1827 | } else { 1828 | switch (PyTuple_GET_SIZE(__pyx_args)) { 1829 | case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); 1830 | case 0: break; 1831 | default: goto __pyx_L5_argtuple_error; 1832 | } 1833 | } 1834 | __pyx_v_value = ((PyObject*)values[0]); 1835 | } 1836 | goto __pyx_L4_argument_unpacking_done; 1837 | __pyx_L5_argtuple_error:; 1838 | __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;} 1839 | __pyx_L3_error:; 1840 | __Pyx_AddTraceback("cityhash.ch128.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); 1841 | __Pyx_RefNannyFinishContext(); 1842 | return -1; 1843 | __pyx_L4_argument_unpacking_done:; 1844 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyBytes_Type), 1, "value", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1845 | 1846 | /* "cityhash.pyx":134 1847 | * cdef public bytes name 1848 | * def __cinit__(self, bytes value=str("")): 1849 | * self.name = str("CityHash128") # <<<<<<<<<<<<<< 1850 | * self.update(value) 1851 | * cpdef update(self, bytes value): 1852 | */ 1853 | __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1854 | __Pyx_GOTREF(__pyx_t_1); 1855 | if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1856 | __Pyx_GIVEREF(__pyx_t_1); 1857 | __Pyx_GOTREF(((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name); 1858 | __Pyx_DECREF(((PyObject *)((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name)); 1859 | ((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name = ((PyObject*)__pyx_t_1); 1860 | __pyx_t_1 = 0; 1861 | 1862 | /* "cityhash.pyx":135 1863 | * def __cinit__(self, bytes value=str("")): 1864 | * self.name = str("CityHash128") 1865 | * self.update(value) # <<<<<<<<<<<<<< 1866 | * cpdef update(self, bytes value): 1867 | * if self.__value: 1868 | */ 1869 | __pyx_t_1 = ((struct __pyx_vtabstruct_8cityhash_ch128 *)((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->__pyx_vtab)->update(((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self), __pyx_v_value, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1870 | __Pyx_GOTREF(__pyx_t_1); 1871 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1872 | 1873 | __pyx_r = 0; 1874 | goto __pyx_L0; 1875 | __pyx_L1_error:; 1876 | __Pyx_XDECREF(__pyx_t_1); 1877 | __Pyx_AddTraceback("cityhash.ch128.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); 1878 | __pyx_r = -1; 1879 | __pyx_L0:; 1880 | __Pyx_RefNannyFinishContext(); 1881 | return __pyx_r; 1882 | } 1883 | 1884 | /* "cityhash.pyx":136 1885 | * self.name = str("CityHash128") 1886 | * self.update(value) 1887 | * cpdef update(self, bytes value): # <<<<<<<<<<<<<< 1888 | * if self.__value: 1889 | * self.__value = CityHash128WithSeed(value, self.__value) 1890 | */ 1891 | 1892 | static PyObject *__pyx_pf_8cityhash_5ch128_1update(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ 1893 | static PyObject *__pyx_f_8cityhash_5ch128_update(struct __pyx_obj_8cityhash_ch128 *__pyx_v_self, PyObject *__pyx_v_value, int __pyx_skip_dispatch) { 1894 | PyObject *__pyx_r = NULL; 1895 | __Pyx_RefNannyDeclarations 1896 | PyObject *__pyx_t_1 = NULL; 1897 | PyObject *__pyx_t_2 = NULL; 1898 | PyObject *__pyx_t_3 = NULL; 1899 | int __pyx_t_4; 1900 | int __pyx_lineno = 0; 1901 | const char *__pyx_filename = NULL; 1902 | int __pyx_clineno = 0; 1903 | __Pyx_RefNannySetupContext("update"); 1904 | /* Check if called by wrapper */ 1905 | if (unlikely(__pyx_skip_dispatch)) ; 1906 | /* Check if overriden in Python */ 1907 | else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { 1908 | __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1909 | __Pyx_GOTREF(__pyx_t_1); 1910 | if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_8cityhash_5ch128_1update)) { 1911 | __Pyx_XDECREF(__pyx_r); 1912 | __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1913 | __Pyx_GOTREF(((PyObject *)__pyx_t_2)); 1914 | __Pyx_INCREF(((PyObject *)__pyx_v_value)); 1915 | PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_value)); 1916 | __Pyx_GIVEREF(((PyObject *)__pyx_v_value)); 1917 | __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1918 | __Pyx_GOTREF(__pyx_t_3); 1919 | __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; 1920 | __pyx_r = __pyx_t_3; 1921 | __pyx_t_3 = 0; 1922 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1923 | goto __pyx_L0; 1924 | } 1925 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1926 | } 1927 | 1928 | /* "cityhash.pyx":137 1929 | * self.update(value) 1930 | * cpdef update(self, bytes value): 1931 | * if self.__value: # <<<<<<<<<<<<<< 1932 | * self.__value = CityHash128WithSeed(value, self.__value) 1933 | * else: 1934 | */ 1935 | __pyx_t_4 = (((PyObject *)__pyx_v_self->__pyx___value) != Py_None) && (PyTuple_GET_SIZE(((PyObject *)__pyx_v_self->__pyx___value)) != 0); 1936 | if (__pyx_t_4) { 1937 | 1938 | /* "cityhash.pyx":138 1939 | * cpdef update(self, bytes value): 1940 | * if self.__value: 1941 | * self.__value = CityHash128WithSeed(value, self.__value) # <<<<<<<<<<<<<< 1942 | * else: 1943 | * self.__value = CityHash128(value) 1944 | */ 1945 | __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx___value); 1946 | __Pyx_INCREF(__pyx_t_1); 1947 | __pyx_t_3 = __pyx_f_8cityhash_CityHash128WithSeed(__pyx_v_value, ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1948 | __Pyx_GOTREF(__pyx_t_3); 1949 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 1950 | if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1951 | __Pyx_GIVEREF(__pyx_t_3); 1952 | __Pyx_GOTREF(__pyx_v_self->__pyx___value); 1953 | __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx___value)); 1954 | __pyx_v_self->__pyx___value = ((PyObject*)__pyx_t_3); 1955 | __pyx_t_3 = 0; 1956 | goto __pyx_L3; 1957 | } 1958 | /*else*/ { 1959 | 1960 | /* "cityhash.pyx":140 1961 | * self.__value = CityHash128WithSeed(value, self.__value) 1962 | * else: 1963 | * self.__value = CityHash128(value) # <<<<<<<<<<<<<< 1964 | * cpdef digest(self): 1965 | * return self.__value 1966 | */ 1967 | __pyx_t_3 = __pyx_f_8cityhash_CityHash128(__pyx_v_value, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1968 | __Pyx_GOTREF(__pyx_t_3); 1969 | if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 1970 | __Pyx_GIVEREF(__pyx_t_3); 1971 | __Pyx_GOTREF(__pyx_v_self->__pyx___value); 1972 | __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx___value)); 1973 | __pyx_v_self->__pyx___value = ((PyObject*)__pyx_t_3); 1974 | __pyx_t_3 = 0; 1975 | } 1976 | __pyx_L3:; 1977 | 1978 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 1979 | goto __pyx_L0; 1980 | __pyx_L1_error:; 1981 | __Pyx_XDECREF(__pyx_t_1); 1982 | __Pyx_XDECREF(__pyx_t_2); 1983 | __Pyx_XDECREF(__pyx_t_3); 1984 | __Pyx_AddTraceback("cityhash.ch128.update", __pyx_clineno, __pyx_lineno, __pyx_filename); 1985 | __pyx_r = 0; 1986 | __pyx_L0:; 1987 | __Pyx_XGIVEREF(__pyx_r); 1988 | __Pyx_RefNannyFinishContext(); 1989 | return __pyx_r; 1990 | } 1991 | 1992 | /* "cityhash.pyx":136 1993 | * self.name = str("CityHash128") 1994 | * self.update(value) 1995 | * cpdef update(self, bytes value): # <<<<<<<<<<<<<< 1996 | * if self.__value: 1997 | * self.__value = CityHash128WithSeed(value, self.__value) 1998 | */ 1999 | 2000 | static PyObject *__pyx_pf_8cityhash_5ch128_1update(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ 2001 | static PyObject *__pyx_pf_8cityhash_5ch128_1update(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { 2002 | PyObject *__pyx_r = NULL; 2003 | __Pyx_RefNannyDeclarations 2004 | PyObject *__pyx_t_1 = NULL; 2005 | int __pyx_lineno = 0; 2006 | const char *__pyx_filename = NULL; 2007 | int __pyx_clineno = 0; 2008 | __Pyx_RefNannySetupContext("update"); 2009 | if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyBytes_Type), 1, "value", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2010 | __Pyx_XDECREF(__pyx_r); 2011 | __pyx_t_1 = ((struct __pyx_vtabstruct_8cityhash_ch128 *)((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->__pyx_vtab)->update(((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self), __pyx_v_value, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2012 | __Pyx_GOTREF(__pyx_t_1); 2013 | __pyx_r = __pyx_t_1; 2014 | __pyx_t_1 = 0; 2015 | goto __pyx_L0; 2016 | 2017 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 2018 | goto __pyx_L0; 2019 | __pyx_L1_error:; 2020 | __Pyx_XDECREF(__pyx_t_1); 2021 | __Pyx_AddTraceback("cityhash.ch128.update", __pyx_clineno, __pyx_lineno, __pyx_filename); 2022 | __pyx_r = NULL; 2023 | __pyx_L0:; 2024 | __Pyx_XGIVEREF(__pyx_r); 2025 | __Pyx_RefNannyFinishContext(); 2026 | return __pyx_r; 2027 | } 2028 | 2029 | /* "cityhash.pyx":141 2030 | * else: 2031 | * self.__value = CityHash128(value) 2032 | * cpdef digest(self): # <<<<<<<<<<<<<< 2033 | * return self.__value 2034 | */ 2035 | 2036 | static PyObject *__pyx_pf_8cityhash_5ch128_2digest(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ 2037 | static PyObject *__pyx_f_8cityhash_5ch128_digest(struct __pyx_obj_8cityhash_ch128 *__pyx_v_self, int __pyx_skip_dispatch) { 2038 | PyObject *__pyx_r = NULL; 2039 | __Pyx_RefNannyDeclarations 2040 | PyObject *__pyx_t_1 = NULL; 2041 | PyObject *__pyx_t_2 = NULL; 2042 | int __pyx_lineno = 0; 2043 | const char *__pyx_filename = NULL; 2044 | int __pyx_clineno = 0; 2045 | __Pyx_RefNannySetupContext("digest"); 2046 | /* Check if called by wrapper */ 2047 | if (unlikely(__pyx_skip_dispatch)) ; 2048 | /* Check if overriden in Python */ 2049 | else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { 2050 | __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__digest); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2051 | __Pyx_GOTREF(__pyx_t_1); 2052 | if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_8cityhash_5ch128_2digest)) { 2053 | __Pyx_XDECREF(__pyx_r); 2054 | __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2055 | __Pyx_GOTREF(__pyx_t_2); 2056 | __pyx_r = __pyx_t_2; 2057 | __pyx_t_2 = 0; 2058 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 2059 | goto __pyx_L0; 2060 | } 2061 | __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 2062 | } 2063 | 2064 | /* "cityhash.pyx":142 2065 | * self.__value = CityHash128(value) 2066 | * cpdef digest(self): 2067 | * return self.__value # <<<<<<<<<<<<<< 2068 | */ 2069 | __Pyx_XDECREF(__pyx_r); 2070 | __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx___value)); 2071 | __pyx_r = ((PyObject *)__pyx_v_self->__pyx___value); 2072 | goto __pyx_L0; 2073 | 2074 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 2075 | goto __pyx_L0; 2076 | __pyx_L1_error:; 2077 | __Pyx_XDECREF(__pyx_t_1); 2078 | __Pyx_XDECREF(__pyx_t_2); 2079 | __Pyx_AddTraceback("cityhash.ch128.digest", __pyx_clineno, __pyx_lineno, __pyx_filename); 2080 | __pyx_r = 0; 2081 | __pyx_L0:; 2082 | __Pyx_XGIVEREF(__pyx_r); 2083 | __Pyx_RefNannyFinishContext(); 2084 | return __pyx_r; 2085 | } 2086 | 2087 | /* "cityhash.pyx":141 2088 | * else: 2089 | * self.__value = CityHash128(value) 2090 | * cpdef digest(self): # <<<<<<<<<<<<<< 2091 | * return self.__value 2092 | */ 2093 | 2094 | static PyObject *__pyx_pf_8cityhash_5ch128_2digest(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ 2095 | static PyObject *__pyx_pf_8cityhash_5ch128_2digest(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { 2096 | PyObject *__pyx_r = NULL; 2097 | __Pyx_RefNannyDeclarations 2098 | PyObject *__pyx_t_1 = NULL; 2099 | int __pyx_lineno = 0; 2100 | const char *__pyx_filename = NULL; 2101 | int __pyx_clineno = 0; 2102 | __Pyx_RefNannySetupContext("digest"); 2103 | __Pyx_XDECREF(__pyx_r); 2104 | __pyx_t_1 = ((struct __pyx_vtabstruct_8cityhash_ch128 *)((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->__pyx_vtab)->digest(((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2105 | __Pyx_GOTREF(__pyx_t_1); 2106 | __pyx_r = __pyx_t_1; 2107 | __pyx_t_1 = 0; 2108 | goto __pyx_L0; 2109 | 2110 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 2111 | goto __pyx_L0; 2112 | __pyx_L1_error:; 2113 | __Pyx_XDECREF(__pyx_t_1); 2114 | __Pyx_AddTraceback("cityhash.ch128.digest", __pyx_clineno, __pyx_lineno, __pyx_filename); 2115 | __pyx_r = NULL; 2116 | __pyx_L0:; 2117 | __Pyx_XGIVEREF(__pyx_r); 2118 | __Pyx_RefNannyFinishContext(); 2119 | return __pyx_r; 2120 | } 2121 | 2122 | /* "cityhash.pyx":132 2123 | * cdef class ch128: 2124 | * cdef tuple __value 2125 | * cdef public bytes name # <<<<<<<<<<<<<< 2126 | * def __cinit__(self, bytes value=str("")): 2127 | * self.name = str("CityHash128") 2128 | */ 2129 | 2130 | static PyObject *__pyx_pf_8cityhash_5ch128_4name___get__(PyObject *__pyx_v_self); /*proto*/ 2131 | static PyObject *__pyx_pf_8cityhash_5ch128_4name___get__(PyObject *__pyx_v_self) { 2132 | PyObject *__pyx_r = NULL; 2133 | __Pyx_RefNannyDeclarations 2134 | __Pyx_RefNannySetupContext("__get__"); 2135 | __Pyx_XDECREF(__pyx_r); 2136 | __Pyx_INCREF(((PyObject *)((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name)); 2137 | __pyx_r = ((PyObject *)((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name); 2138 | goto __pyx_L0; 2139 | 2140 | __pyx_r = Py_None; __Pyx_INCREF(Py_None); 2141 | __pyx_L0:; 2142 | __Pyx_XGIVEREF(__pyx_r); 2143 | __Pyx_RefNannyFinishContext(); 2144 | return __pyx_r; 2145 | } 2146 | 2147 | static int __pyx_pf_8cityhash_5ch128_4name_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ 2148 | static int __pyx_pf_8cityhash_5ch128_4name_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { 2149 | int __pyx_r; 2150 | __Pyx_RefNannyDeclarations 2151 | int __pyx_lineno = 0; 2152 | const char *__pyx_filename = NULL; 2153 | int __pyx_clineno = 0; 2154 | __Pyx_RefNannySetupContext("__set__"); 2155 | if (!(likely(PyBytes_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2156 | __Pyx_INCREF(__pyx_v_value); 2157 | __Pyx_GIVEREF(__pyx_v_value); 2158 | __Pyx_GOTREF(((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name); 2159 | __Pyx_DECREF(((PyObject *)((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name)); 2160 | ((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name = ((PyObject*)__pyx_v_value); 2161 | 2162 | __pyx_r = 0; 2163 | goto __pyx_L0; 2164 | __pyx_L1_error:; 2165 | __Pyx_AddTraceback("cityhash.ch128.name.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); 2166 | __pyx_r = -1; 2167 | __pyx_L0:; 2168 | __Pyx_RefNannyFinishContext(); 2169 | return __pyx_r; 2170 | } 2171 | 2172 | static int __pyx_pf_8cityhash_5ch128_4name_2__del__(PyObject *__pyx_v_self); /*proto*/ 2173 | static int __pyx_pf_8cityhash_5ch128_4name_2__del__(PyObject *__pyx_v_self) { 2174 | int __pyx_r; 2175 | __Pyx_RefNannyDeclarations 2176 | __Pyx_RefNannySetupContext("__del__"); 2177 | __Pyx_INCREF(Py_None); 2178 | __Pyx_GIVEREF(Py_None); 2179 | __Pyx_GOTREF(((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name); 2180 | __Pyx_DECREF(((PyObject *)((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name)); 2181 | ((struct __pyx_obj_8cityhash_ch128 *)__pyx_v_self)->name = ((PyObject*)Py_None); 2182 | 2183 | __pyx_r = 0; 2184 | __Pyx_RefNannyFinishContext(); 2185 | return __pyx_r; 2186 | } 2187 | static struct __pyx_vtabstruct_8cityhash_ch64 __pyx_vtable_8cityhash_ch64; 2188 | 2189 | static PyObject *__pyx_tp_new_8cityhash_ch64(PyTypeObject *t, PyObject *a, PyObject *k) { 2190 | struct __pyx_obj_8cityhash_ch64 *p; 2191 | PyObject *o = (*t->tp_alloc)(t, 0); 2192 | if (!o) return 0; 2193 | p = ((struct __pyx_obj_8cityhash_ch64 *)o); 2194 | p->__pyx_vtab = __pyx_vtabptr_8cityhash_ch64; 2195 | p->name = ((PyObject*)Py_None); Py_INCREF(Py_None); 2196 | if (__pyx_pf_8cityhash_4ch64___cinit__(o, a, k) < 0) { 2197 | Py_DECREF(o); o = 0; 2198 | } 2199 | return o; 2200 | } 2201 | 2202 | static void __pyx_tp_dealloc_8cityhash_ch64(PyObject *o) { 2203 | struct __pyx_obj_8cityhash_ch64 *p = (struct __pyx_obj_8cityhash_ch64 *)o; 2204 | Py_XDECREF(((PyObject *)p->name)); 2205 | (*Py_TYPE(o)->tp_free)(o); 2206 | } 2207 | 2208 | static int __pyx_tp_traverse_8cityhash_ch64(PyObject *o, visitproc v, void *a) { 2209 | int e; 2210 | struct __pyx_obj_8cityhash_ch64 *p = (struct __pyx_obj_8cityhash_ch64 *)o; 2211 | if (p->name) { 2212 | e = (*v)(p->name, a); if (e) return e; 2213 | } 2214 | return 0; 2215 | } 2216 | 2217 | static int __pyx_tp_clear_8cityhash_ch64(PyObject *o) { 2218 | struct __pyx_obj_8cityhash_ch64 *p = (struct __pyx_obj_8cityhash_ch64 *)o; 2219 | PyObject* tmp; 2220 | tmp = ((PyObject*)p->name); 2221 | p->name = ((PyObject*)Py_None); Py_INCREF(Py_None); 2222 | Py_XDECREF(tmp); 2223 | return 0; 2224 | } 2225 | 2226 | static PyObject *__pyx_getprop_8cityhash_4ch64_name(PyObject *o, void *x) { 2227 | return __pyx_pf_8cityhash_4ch64_4name___get__(o); 2228 | } 2229 | 2230 | static int __pyx_setprop_8cityhash_4ch64_name(PyObject *o, PyObject *v, void *x) { 2231 | if (v) { 2232 | return __pyx_pf_8cityhash_4ch64_4name_1__set__(o, v); 2233 | } 2234 | else { 2235 | return __pyx_pf_8cityhash_4ch64_4name_2__del__(o); 2236 | } 2237 | } 2238 | 2239 | static PyMethodDef __pyx_methods_8cityhash_ch64[] = { 2240 | {__Pyx_NAMESTR("update"), (PyCFunction)__pyx_pf_8cityhash_4ch64_1update, METH_O, __Pyx_DOCSTR(0)}, 2241 | {__Pyx_NAMESTR("digest"), (PyCFunction)__pyx_pf_8cityhash_4ch64_2digest, METH_NOARGS, __Pyx_DOCSTR(0)}, 2242 | {0, 0, 0, 0} 2243 | }; 2244 | 2245 | static struct PyGetSetDef __pyx_getsets_8cityhash_ch64[] = { 2246 | {(char *)"name", __pyx_getprop_8cityhash_4ch64_name, __pyx_setprop_8cityhash_4ch64_name, 0, 0}, 2247 | {0, 0, 0, 0, 0} 2248 | }; 2249 | 2250 | static PyNumberMethods __pyx_tp_as_number_ch64 = { 2251 | 0, /*nb_add*/ 2252 | 0, /*nb_subtract*/ 2253 | 0, /*nb_multiply*/ 2254 | #if PY_MAJOR_VERSION < 3 2255 | 0, /*nb_divide*/ 2256 | #endif 2257 | 0, /*nb_remainder*/ 2258 | 0, /*nb_divmod*/ 2259 | 0, /*nb_power*/ 2260 | 0, /*nb_negative*/ 2261 | 0, /*nb_positive*/ 2262 | 0, /*nb_absolute*/ 2263 | 0, /*nb_nonzero*/ 2264 | 0, /*nb_invert*/ 2265 | 0, /*nb_lshift*/ 2266 | 0, /*nb_rshift*/ 2267 | 0, /*nb_and*/ 2268 | 0, /*nb_xor*/ 2269 | 0, /*nb_or*/ 2270 | #if PY_MAJOR_VERSION < 3 2271 | 0, /*nb_coerce*/ 2272 | #endif 2273 | 0, /*nb_int*/ 2274 | #if PY_MAJOR_VERSION < 3 2275 | 0, /*nb_long*/ 2276 | #else 2277 | 0, /*reserved*/ 2278 | #endif 2279 | 0, /*nb_float*/ 2280 | #if PY_MAJOR_VERSION < 3 2281 | 0, /*nb_oct*/ 2282 | #endif 2283 | #if PY_MAJOR_VERSION < 3 2284 | 0, /*nb_hex*/ 2285 | #endif 2286 | 0, /*nb_inplace_add*/ 2287 | 0, /*nb_inplace_subtract*/ 2288 | 0, /*nb_inplace_multiply*/ 2289 | #if PY_MAJOR_VERSION < 3 2290 | 0, /*nb_inplace_divide*/ 2291 | #endif 2292 | 0, /*nb_inplace_remainder*/ 2293 | 0, /*nb_inplace_power*/ 2294 | 0, /*nb_inplace_lshift*/ 2295 | 0, /*nb_inplace_rshift*/ 2296 | 0, /*nb_inplace_and*/ 2297 | 0, /*nb_inplace_xor*/ 2298 | 0, /*nb_inplace_or*/ 2299 | 0, /*nb_floor_divide*/ 2300 | 0, /*nb_true_divide*/ 2301 | 0, /*nb_inplace_floor_divide*/ 2302 | 0, /*nb_inplace_true_divide*/ 2303 | #if PY_VERSION_HEX >= 0x02050000 2304 | 0, /*nb_index*/ 2305 | #endif 2306 | }; 2307 | 2308 | static PySequenceMethods __pyx_tp_as_sequence_ch64 = { 2309 | 0, /*sq_length*/ 2310 | 0, /*sq_concat*/ 2311 | 0, /*sq_repeat*/ 2312 | 0, /*sq_item*/ 2313 | 0, /*sq_slice*/ 2314 | 0, /*sq_ass_item*/ 2315 | 0, /*sq_ass_slice*/ 2316 | 0, /*sq_contains*/ 2317 | 0, /*sq_inplace_concat*/ 2318 | 0, /*sq_inplace_repeat*/ 2319 | }; 2320 | 2321 | static PyMappingMethods __pyx_tp_as_mapping_ch64 = { 2322 | 0, /*mp_length*/ 2323 | 0, /*mp_subscript*/ 2324 | 0, /*mp_ass_subscript*/ 2325 | }; 2326 | 2327 | static PyBufferProcs __pyx_tp_as_buffer_ch64 = { 2328 | #if PY_MAJOR_VERSION < 3 2329 | 0, /*bf_getreadbuffer*/ 2330 | #endif 2331 | #if PY_MAJOR_VERSION < 3 2332 | 0, /*bf_getwritebuffer*/ 2333 | #endif 2334 | #if PY_MAJOR_VERSION < 3 2335 | 0, /*bf_getsegcount*/ 2336 | #endif 2337 | #if PY_MAJOR_VERSION < 3 2338 | 0, /*bf_getcharbuffer*/ 2339 | #endif 2340 | #if PY_VERSION_HEX >= 0x02060000 2341 | 0, /*bf_getbuffer*/ 2342 | #endif 2343 | #if PY_VERSION_HEX >= 0x02060000 2344 | 0, /*bf_releasebuffer*/ 2345 | #endif 2346 | }; 2347 | 2348 | static PyTypeObject __pyx_type_8cityhash_ch64 = { 2349 | PyVarObject_HEAD_INIT(0, 0) 2350 | __Pyx_NAMESTR("cityhash.ch64"), /*tp_name*/ 2351 | sizeof(struct __pyx_obj_8cityhash_ch64), /*tp_basicsize*/ 2352 | 0, /*tp_itemsize*/ 2353 | __pyx_tp_dealloc_8cityhash_ch64, /*tp_dealloc*/ 2354 | 0, /*tp_print*/ 2355 | 0, /*tp_getattr*/ 2356 | 0, /*tp_setattr*/ 2357 | #if PY_MAJOR_VERSION < 3 2358 | 0, /*tp_compare*/ 2359 | #else 2360 | 0, /*reserved*/ 2361 | #endif 2362 | 0, /*tp_repr*/ 2363 | &__pyx_tp_as_number_ch64, /*tp_as_number*/ 2364 | &__pyx_tp_as_sequence_ch64, /*tp_as_sequence*/ 2365 | &__pyx_tp_as_mapping_ch64, /*tp_as_mapping*/ 2366 | 0, /*tp_hash*/ 2367 | 0, /*tp_call*/ 2368 | 0, /*tp_str*/ 2369 | 0, /*tp_getattro*/ 2370 | 0, /*tp_setattro*/ 2371 | &__pyx_tp_as_buffer_ch64, /*tp_as_buffer*/ 2372 | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 2373 | 0, /*tp_doc*/ 2374 | __pyx_tp_traverse_8cityhash_ch64, /*tp_traverse*/ 2375 | __pyx_tp_clear_8cityhash_ch64, /*tp_clear*/ 2376 | 0, /*tp_richcompare*/ 2377 | 0, /*tp_weaklistoffset*/ 2378 | 0, /*tp_iter*/ 2379 | 0, /*tp_iternext*/ 2380 | __pyx_methods_8cityhash_ch64, /*tp_methods*/ 2381 | 0, /*tp_members*/ 2382 | __pyx_getsets_8cityhash_ch64, /*tp_getset*/ 2383 | 0, /*tp_base*/ 2384 | 0, /*tp_dict*/ 2385 | 0, /*tp_descr_get*/ 2386 | 0, /*tp_descr_set*/ 2387 | 0, /*tp_dictoffset*/ 2388 | 0, /*tp_init*/ 2389 | 0, /*tp_alloc*/ 2390 | __pyx_tp_new_8cityhash_ch64, /*tp_new*/ 2391 | 0, /*tp_free*/ 2392 | 0, /*tp_is_gc*/ 2393 | 0, /*tp_bases*/ 2394 | 0, /*tp_mro*/ 2395 | 0, /*tp_cache*/ 2396 | 0, /*tp_subclasses*/ 2397 | 0, /*tp_weaklist*/ 2398 | 0, /*tp_del*/ 2399 | #if PY_VERSION_HEX >= 0x02060000 2400 | 0, /*tp_version_tag*/ 2401 | #endif 2402 | }; 2403 | static struct __pyx_vtabstruct_8cityhash_ch128 __pyx_vtable_8cityhash_ch128; 2404 | 2405 | static PyObject *__pyx_tp_new_8cityhash_ch128(PyTypeObject *t, PyObject *a, PyObject *k) { 2406 | struct __pyx_obj_8cityhash_ch128 *p; 2407 | PyObject *o = (*t->tp_alloc)(t, 0); 2408 | if (!o) return 0; 2409 | p = ((struct __pyx_obj_8cityhash_ch128 *)o); 2410 | p->__pyx_vtab = __pyx_vtabptr_8cityhash_ch128; 2411 | p->__pyx___value = ((PyObject*)Py_None); Py_INCREF(Py_None); 2412 | p->name = ((PyObject*)Py_None); Py_INCREF(Py_None); 2413 | if (__pyx_pf_8cityhash_5ch128___cinit__(o, a, k) < 0) { 2414 | Py_DECREF(o); o = 0; 2415 | } 2416 | return o; 2417 | } 2418 | 2419 | static void __pyx_tp_dealloc_8cityhash_ch128(PyObject *o) { 2420 | struct __pyx_obj_8cityhash_ch128 *p = (struct __pyx_obj_8cityhash_ch128 *)o; 2421 | Py_XDECREF(((PyObject *)p->__pyx___value)); 2422 | Py_XDECREF(((PyObject *)p->name)); 2423 | (*Py_TYPE(o)->tp_free)(o); 2424 | } 2425 | 2426 | static int __pyx_tp_traverse_8cityhash_ch128(PyObject *o, visitproc v, void *a) { 2427 | int e; 2428 | struct __pyx_obj_8cityhash_ch128 *p = (struct __pyx_obj_8cityhash_ch128 *)o; 2429 | if (p->__pyx___value) { 2430 | e = (*v)(p->__pyx___value, a); if (e) return e; 2431 | } 2432 | if (p->name) { 2433 | e = (*v)(p->name, a); if (e) return e; 2434 | } 2435 | return 0; 2436 | } 2437 | 2438 | static int __pyx_tp_clear_8cityhash_ch128(PyObject *o) { 2439 | struct __pyx_obj_8cityhash_ch128 *p = (struct __pyx_obj_8cityhash_ch128 *)o; 2440 | PyObject* tmp; 2441 | tmp = ((PyObject*)p->__pyx___value); 2442 | p->__pyx___value = ((PyObject*)Py_None); Py_INCREF(Py_None); 2443 | Py_XDECREF(tmp); 2444 | tmp = ((PyObject*)p->name); 2445 | p->name = ((PyObject*)Py_None); Py_INCREF(Py_None); 2446 | Py_XDECREF(tmp); 2447 | return 0; 2448 | } 2449 | 2450 | static PyObject *__pyx_getprop_8cityhash_5ch128_name(PyObject *o, void *x) { 2451 | return __pyx_pf_8cityhash_5ch128_4name___get__(o); 2452 | } 2453 | 2454 | static int __pyx_setprop_8cityhash_5ch128_name(PyObject *o, PyObject *v, void *x) { 2455 | if (v) { 2456 | return __pyx_pf_8cityhash_5ch128_4name_1__set__(o, v); 2457 | } 2458 | else { 2459 | return __pyx_pf_8cityhash_5ch128_4name_2__del__(o); 2460 | } 2461 | } 2462 | 2463 | static PyMethodDef __pyx_methods_8cityhash_ch128[] = { 2464 | {__Pyx_NAMESTR("update"), (PyCFunction)__pyx_pf_8cityhash_5ch128_1update, METH_O, __Pyx_DOCSTR(0)}, 2465 | {__Pyx_NAMESTR("digest"), (PyCFunction)__pyx_pf_8cityhash_5ch128_2digest, METH_NOARGS, __Pyx_DOCSTR(0)}, 2466 | {0, 0, 0, 0} 2467 | }; 2468 | 2469 | static struct PyGetSetDef __pyx_getsets_8cityhash_ch128[] = { 2470 | {(char *)"name", __pyx_getprop_8cityhash_5ch128_name, __pyx_setprop_8cityhash_5ch128_name, 0, 0}, 2471 | {0, 0, 0, 0, 0} 2472 | }; 2473 | 2474 | static PyNumberMethods __pyx_tp_as_number_ch128 = { 2475 | 0, /*nb_add*/ 2476 | 0, /*nb_subtract*/ 2477 | 0, /*nb_multiply*/ 2478 | #if PY_MAJOR_VERSION < 3 2479 | 0, /*nb_divide*/ 2480 | #endif 2481 | 0, /*nb_remainder*/ 2482 | 0, /*nb_divmod*/ 2483 | 0, /*nb_power*/ 2484 | 0, /*nb_negative*/ 2485 | 0, /*nb_positive*/ 2486 | 0, /*nb_absolute*/ 2487 | 0, /*nb_nonzero*/ 2488 | 0, /*nb_invert*/ 2489 | 0, /*nb_lshift*/ 2490 | 0, /*nb_rshift*/ 2491 | 0, /*nb_and*/ 2492 | 0, /*nb_xor*/ 2493 | 0, /*nb_or*/ 2494 | #if PY_MAJOR_VERSION < 3 2495 | 0, /*nb_coerce*/ 2496 | #endif 2497 | 0, /*nb_int*/ 2498 | #if PY_MAJOR_VERSION < 3 2499 | 0, /*nb_long*/ 2500 | #else 2501 | 0, /*reserved*/ 2502 | #endif 2503 | 0, /*nb_float*/ 2504 | #if PY_MAJOR_VERSION < 3 2505 | 0, /*nb_oct*/ 2506 | #endif 2507 | #if PY_MAJOR_VERSION < 3 2508 | 0, /*nb_hex*/ 2509 | #endif 2510 | 0, /*nb_inplace_add*/ 2511 | 0, /*nb_inplace_subtract*/ 2512 | 0, /*nb_inplace_multiply*/ 2513 | #if PY_MAJOR_VERSION < 3 2514 | 0, /*nb_inplace_divide*/ 2515 | #endif 2516 | 0, /*nb_inplace_remainder*/ 2517 | 0, /*nb_inplace_power*/ 2518 | 0, /*nb_inplace_lshift*/ 2519 | 0, /*nb_inplace_rshift*/ 2520 | 0, /*nb_inplace_and*/ 2521 | 0, /*nb_inplace_xor*/ 2522 | 0, /*nb_inplace_or*/ 2523 | 0, /*nb_floor_divide*/ 2524 | 0, /*nb_true_divide*/ 2525 | 0, /*nb_inplace_floor_divide*/ 2526 | 0, /*nb_inplace_true_divide*/ 2527 | #if PY_VERSION_HEX >= 0x02050000 2528 | 0, /*nb_index*/ 2529 | #endif 2530 | }; 2531 | 2532 | static PySequenceMethods __pyx_tp_as_sequence_ch128 = { 2533 | 0, /*sq_length*/ 2534 | 0, /*sq_concat*/ 2535 | 0, /*sq_repeat*/ 2536 | 0, /*sq_item*/ 2537 | 0, /*sq_slice*/ 2538 | 0, /*sq_ass_item*/ 2539 | 0, /*sq_ass_slice*/ 2540 | 0, /*sq_contains*/ 2541 | 0, /*sq_inplace_concat*/ 2542 | 0, /*sq_inplace_repeat*/ 2543 | }; 2544 | 2545 | static PyMappingMethods __pyx_tp_as_mapping_ch128 = { 2546 | 0, /*mp_length*/ 2547 | 0, /*mp_subscript*/ 2548 | 0, /*mp_ass_subscript*/ 2549 | }; 2550 | 2551 | static PyBufferProcs __pyx_tp_as_buffer_ch128 = { 2552 | #if PY_MAJOR_VERSION < 3 2553 | 0, /*bf_getreadbuffer*/ 2554 | #endif 2555 | #if PY_MAJOR_VERSION < 3 2556 | 0, /*bf_getwritebuffer*/ 2557 | #endif 2558 | #if PY_MAJOR_VERSION < 3 2559 | 0, /*bf_getsegcount*/ 2560 | #endif 2561 | #if PY_MAJOR_VERSION < 3 2562 | 0, /*bf_getcharbuffer*/ 2563 | #endif 2564 | #if PY_VERSION_HEX >= 0x02060000 2565 | 0, /*bf_getbuffer*/ 2566 | #endif 2567 | #if PY_VERSION_HEX >= 0x02060000 2568 | 0, /*bf_releasebuffer*/ 2569 | #endif 2570 | }; 2571 | 2572 | static PyTypeObject __pyx_type_8cityhash_ch128 = { 2573 | PyVarObject_HEAD_INIT(0, 0) 2574 | __Pyx_NAMESTR("cityhash.ch128"), /*tp_name*/ 2575 | sizeof(struct __pyx_obj_8cityhash_ch128), /*tp_basicsize*/ 2576 | 0, /*tp_itemsize*/ 2577 | __pyx_tp_dealloc_8cityhash_ch128, /*tp_dealloc*/ 2578 | 0, /*tp_print*/ 2579 | 0, /*tp_getattr*/ 2580 | 0, /*tp_setattr*/ 2581 | #if PY_MAJOR_VERSION < 3 2582 | 0, /*tp_compare*/ 2583 | #else 2584 | 0, /*reserved*/ 2585 | #endif 2586 | 0, /*tp_repr*/ 2587 | &__pyx_tp_as_number_ch128, /*tp_as_number*/ 2588 | &__pyx_tp_as_sequence_ch128, /*tp_as_sequence*/ 2589 | &__pyx_tp_as_mapping_ch128, /*tp_as_mapping*/ 2590 | 0, /*tp_hash*/ 2591 | 0, /*tp_call*/ 2592 | 0, /*tp_str*/ 2593 | 0, /*tp_getattro*/ 2594 | 0, /*tp_setattro*/ 2595 | &__pyx_tp_as_buffer_ch128, /*tp_as_buffer*/ 2596 | Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 2597 | 0, /*tp_doc*/ 2598 | __pyx_tp_traverse_8cityhash_ch128, /*tp_traverse*/ 2599 | __pyx_tp_clear_8cityhash_ch128, /*tp_clear*/ 2600 | 0, /*tp_richcompare*/ 2601 | 0, /*tp_weaklistoffset*/ 2602 | 0, /*tp_iter*/ 2603 | 0, /*tp_iternext*/ 2604 | __pyx_methods_8cityhash_ch128, /*tp_methods*/ 2605 | 0, /*tp_members*/ 2606 | __pyx_getsets_8cityhash_ch128, /*tp_getset*/ 2607 | 0, /*tp_base*/ 2608 | 0, /*tp_dict*/ 2609 | 0, /*tp_descr_get*/ 2610 | 0, /*tp_descr_set*/ 2611 | 0, /*tp_dictoffset*/ 2612 | 0, /*tp_init*/ 2613 | 0, /*tp_alloc*/ 2614 | __pyx_tp_new_8cityhash_ch128, /*tp_new*/ 2615 | 0, /*tp_free*/ 2616 | 0, /*tp_is_gc*/ 2617 | 0, /*tp_bases*/ 2618 | 0, /*tp_mro*/ 2619 | 0, /*tp_cache*/ 2620 | 0, /*tp_subclasses*/ 2621 | 0, /*tp_weaklist*/ 2622 | 0, /*tp_del*/ 2623 | #if PY_VERSION_HEX >= 0x02060000 2624 | 0, /*tp_version_tag*/ 2625 | #endif 2626 | }; 2627 | 2628 | static PyMethodDef __pyx_methods[] = { 2629 | {__Pyx_NAMESTR("CityHash64"), (PyCFunction)__pyx_pf_8cityhash_CityHash64, METH_O, __Pyx_DOCSTR(__pyx_doc_8cityhash_CityHash64)}, 2630 | {__Pyx_NAMESTR("CityHash64WithSeed"), (PyCFunction)__pyx_pf_8cityhash_1CityHash64WithSeed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8cityhash_1CityHash64WithSeed)}, 2631 | {__Pyx_NAMESTR("CityHash64WithSeeds"), (PyCFunction)__pyx_pf_8cityhash_2CityHash64WithSeeds, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8cityhash_2CityHash64WithSeeds)}, 2632 | {__Pyx_NAMESTR("CityHash128"), (PyCFunction)__pyx_pf_8cityhash_3CityHash128, METH_O, __Pyx_DOCSTR(__pyx_doc_8cityhash_3CityHash128)}, 2633 | {__Pyx_NAMESTR("CityHash128WithSeed"), (PyCFunction)__pyx_pf_8cityhash_4CityHash128WithSeed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8cityhash_4CityHash128WithSeed)}, 2634 | {__Pyx_NAMESTR("Hash128to64"), (PyCFunction)__pyx_pf_8cityhash_5Hash128to64, METH_O, __Pyx_DOCSTR(__pyx_doc_8cityhash_5Hash128to64)}, 2635 | {0, 0, 0, 0} 2636 | }; 2637 | 2638 | #if PY_MAJOR_VERSION >= 3 2639 | static struct PyModuleDef __pyx_moduledef = { 2640 | PyModuleDef_HEAD_INIT, 2641 | __Pyx_NAMESTR("cityhash"), 2642 | __Pyx_DOCSTR(__pyx_k_5), /* m_doc */ 2643 | -1, /* m_size */ 2644 | __pyx_methods /* m_methods */, 2645 | NULL, /* m_reload */ 2646 | NULL, /* m_traverse */ 2647 | NULL, /* m_clear */ 2648 | NULL /* m_free */ 2649 | }; 2650 | #endif 2651 | 2652 | static __Pyx_StringTabEntry __pyx_string_tab[] = { 2653 | {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0}, 2654 | {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0}, 2655 | {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0}, 2656 | {&__pyx_n_s__CityHash128, __pyx_k__CityHash128, sizeof(__pyx_k__CityHash128), 0, 0, 1, 1}, 2657 | {&__pyx_n_s__CityHash128WithSeed, __pyx_k__CityHash128WithSeed, sizeof(__pyx_k__CityHash128WithSeed), 0, 0, 1, 1}, 2658 | {&__pyx_n_s__CityHash64, __pyx_k__CityHash64, sizeof(__pyx_k__CityHash64), 0, 0, 1, 1}, 2659 | {&__pyx_n_s__CityHash64WithSeed, __pyx_k__CityHash64WithSeed, sizeof(__pyx_k__CityHash64WithSeed), 0, 0, 1, 1}, 2660 | {&__pyx_n_s__CityHash64WithSeeds, __pyx_k__CityHash64WithSeeds, sizeof(__pyx_k__CityHash64WithSeeds), 0, 0, 1, 1}, 2661 | {&__pyx_n_s__Hash128to64, __pyx_k__Hash128to64, sizeof(__pyx_k__Hash128to64), 0, 0, 1, 1}, 2662 | {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1}, 2663 | {&__pyx_n_s____author__, __pyx_k____author__, sizeof(__pyx_k____author__), 0, 0, 1, 1}, 2664 | {&__pyx_n_s____email__, __pyx_k____email__, sizeof(__pyx_k____email__), 0, 0, 1, 1}, 2665 | {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, 2666 | {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, 2667 | {&__pyx_n_s__buf, __pyx_k__buf, sizeof(__pyx_k__buf), 0, 0, 1, 1}, 2668 | {&__pyx_n_s__ch128, __pyx_k__ch128, sizeof(__pyx_k__ch128), 0, 0, 1, 1}, 2669 | {&__pyx_n_s__ch64, __pyx_k__ch64, sizeof(__pyx_k__ch64), 0, 0, 1, 1}, 2670 | {&__pyx_n_s__digest, __pyx_k__digest, sizeof(__pyx_k__digest), 0, 0, 1, 1}, 2671 | {&__pyx_n_s__seed, __pyx_k__seed, sizeof(__pyx_k__seed), 0, 0, 1, 1}, 2672 | {&__pyx_n_s__seed0, __pyx_k__seed0, sizeof(__pyx_k__seed0), 0, 0, 1, 1}, 2673 | {&__pyx_n_s__seed1, __pyx_k__seed1, sizeof(__pyx_k__seed1), 0, 0, 1, 1}, 2674 | {&__pyx_n_s__update, __pyx_k__update, sizeof(__pyx_k__update), 0, 0, 1, 1}, 2675 | {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1}, 2676 | {0, 0, 0, 0, 0, 0, 0} 2677 | }; 2678 | static int __Pyx_InitCachedBuiltins(void) { 2679 | return 0; 2680 | } 2681 | 2682 | static int __Pyx_InitCachedConstants(void) { 2683 | __Pyx_RefNannyDeclarations 2684 | __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants"); 2685 | 2686 | /* "cityhash.pyx":120 2687 | * cdef public bytes name 2688 | * def __cinit__(self, bytes value=str("")): 2689 | * self.name = str("CityHash64") # <<<<<<<<<<<<<< 2690 | * self.update(value) 2691 | * cpdef update(self, bytes value): 2692 | */ 2693 | __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2694 | __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_2)); 2695 | __Pyx_INCREF(((PyObject *)__pyx_n_s__CityHash64)); 2696 | PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_n_s__CityHash64)); 2697 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CityHash64)); 2698 | __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2)); 2699 | 2700 | /* "cityhash.pyx":134 2701 | * cdef public bytes name 2702 | * def __cinit__(self, bytes value=str("")): 2703 | * self.name = str("CityHash128") # <<<<<<<<<<<<<< 2704 | * self.update(value) 2705 | * cpdef update(self, bytes value): 2706 | */ 2707 | __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2708 | __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4)); 2709 | __Pyx_INCREF(((PyObject *)__pyx_n_s__CityHash128)); 2710 | PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_n_s__CityHash128)); 2711 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CityHash128)); 2712 | __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4)); 2713 | 2714 | /* "cityhash.pyx":119 2715 | * cdef uint64 __value 2716 | * cdef public bytes name 2717 | * def __cinit__(self, bytes value=str("")): # <<<<<<<<<<<<<< 2718 | * self.name = str("CityHash64") 2719 | * self.update(value) 2720 | */ 2721 | __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2722 | __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9)); 2723 | __Pyx_INCREF(((PyObject *)__pyx_kp_s_8)); 2724 | PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8)); 2725 | __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8)); 2726 | __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9)); 2727 | 2728 | /* "cityhash.pyx":133 2729 | * cdef tuple __value 2730 | * cdef public bytes name 2731 | * def __cinit__(self, bytes value=str("")): # <<<<<<<<<<<<<< 2732 | * self.name = str("CityHash128") 2733 | * self.update(value) 2734 | */ 2735 | __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2736 | __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_10)); 2737 | __Pyx_INCREF(((PyObject *)__pyx_kp_s_8)); 2738 | PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_s_8)); 2739 | __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8)); 2740 | __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); 2741 | __Pyx_RefNannyFinishContext(); 2742 | return 0; 2743 | __pyx_L1_error:; 2744 | __Pyx_RefNannyFinishContext(); 2745 | return -1; 2746 | } 2747 | 2748 | static int __Pyx_InitGlobals(void) { 2749 | if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 2750 | return 0; 2751 | __pyx_L1_error:; 2752 | return -1; 2753 | } 2754 | 2755 | #if PY_MAJOR_VERSION < 3 2756 | PyMODINIT_FUNC initcityhash(void); /*proto*/ 2757 | PyMODINIT_FUNC initcityhash(void) 2758 | #else 2759 | PyMODINIT_FUNC PyInit_cityhash(void); /*proto*/ 2760 | PyMODINIT_FUNC PyInit_cityhash(void) 2761 | #endif 2762 | { 2763 | PyObject *__pyx_t_1 = NULL; 2764 | __Pyx_RefNannyDeclarations 2765 | #if CYTHON_REFNANNY 2766 | __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); 2767 | if (!__Pyx_RefNanny) { 2768 | PyErr_Clear(); 2769 | __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); 2770 | if (!__Pyx_RefNanny) 2771 | Py_FatalError("failed to import 'refnanny' module"); 2772 | } 2773 | #endif 2774 | __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_cityhash(void)"); 2775 | if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2776 | __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2777 | __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2778 | #ifdef __pyx_binding_PyCFunctionType_USED 2779 | if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2780 | #endif 2781 | /*--- Library function declarations ---*/ 2782 | /*--- Threads initialization code ---*/ 2783 | #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS 2784 | #ifdef WITH_THREAD /* Python build with threading support? */ 2785 | PyEval_InitThreads(); 2786 | #endif 2787 | #endif 2788 | /*--- Module creation code ---*/ 2789 | #if PY_MAJOR_VERSION < 3 2790 | __pyx_m = Py_InitModule4(__Pyx_NAMESTR("cityhash"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_5), 0, PYTHON_API_VERSION); 2791 | #else 2792 | __pyx_m = PyModule_Create(&__pyx_moduledef); 2793 | #endif 2794 | if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 2795 | #if PY_MAJOR_VERSION < 3 2796 | Py_INCREF(__pyx_m); 2797 | #endif 2798 | __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); 2799 | if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 2800 | if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 2801 | /*--- Initialize various global constants etc. ---*/ 2802 | if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2803 | if (__pyx_module_is_main_cityhash) { 2804 | if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 2805 | } 2806 | /*--- Builtin init code ---*/ 2807 | if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2808 | /*--- Constants init code ---*/ 2809 | if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2810 | /*--- Global init code ---*/ 2811 | /*--- Variable export code ---*/ 2812 | /*--- Function export code ---*/ 2813 | /*--- Type init code ---*/ 2814 | __pyx_vtabptr_8cityhash_ch64 = &__pyx_vtable_8cityhash_ch64; 2815 | __pyx_vtable_8cityhash_ch64.update = (PyObject *(*)(struct __pyx_obj_8cityhash_ch64 *, PyObject *, int __pyx_skip_dispatch))__pyx_f_8cityhash_4ch64_update; 2816 | __pyx_vtable_8cityhash_ch64.digest = (PyObject *(*)(struct __pyx_obj_8cityhash_ch64 *, int __pyx_skip_dispatch))__pyx_f_8cityhash_4ch64_digest; 2817 | if (PyType_Ready(&__pyx_type_8cityhash_ch64) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2818 | if (__Pyx_SetVtable(__pyx_type_8cityhash_ch64.tp_dict, __pyx_vtabptr_8cityhash_ch64) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2819 | if (__Pyx_SetAttrString(__pyx_m, "ch64", (PyObject *)&__pyx_type_8cityhash_ch64) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2820 | __pyx_ptype_8cityhash_ch64 = &__pyx_type_8cityhash_ch64; 2821 | __pyx_vtabptr_8cityhash_ch128 = &__pyx_vtable_8cityhash_ch128; 2822 | __pyx_vtable_8cityhash_ch128.update = (PyObject *(*)(struct __pyx_obj_8cityhash_ch128 *, PyObject *, int __pyx_skip_dispatch))__pyx_f_8cityhash_5ch128_update; 2823 | __pyx_vtable_8cityhash_ch128.digest = (PyObject *(*)(struct __pyx_obj_8cityhash_ch128 *, int __pyx_skip_dispatch))__pyx_f_8cityhash_5ch128_digest; 2824 | if (PyType_Ready(&__pyx_type_8cityhash_ch128) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2825 | if (__Pyx_SetVtable(__pyx_type_8cityhash_ch128.tp_dict, __pyx_vtabptr_8cityhash_ch128) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2826 | if (__Pyx_SetAttrString(__pyx_m, "ch128", (PyObject *)&__pyx_type_8cityhash_ch128) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2827 | __pyx_ptype_8cityhash_ch128 = &__pyx_type_8cityhash_ch128; 2828 | /*--- Type import code ---*/ 2829 | /*--- Variable import code ---*/ 2830 | /*--- Function import code ---*/ 2831 | /*--- Execution code ---*/ 2832 | 2833 | /* "cityhash.pyx":25 2834 | * """ 2835 | * 2836 | * __author__ = "Alexander [Amper] Marshalov" # <<<<<<<<<<<<<< 2837 | * __email__ = "alone.amper+cityhash@gmail.com" 2838 | * __all__ = ["CityHash64", 2839 | */ 2840 | if (PyObject_SetAttr(__pyx_m, __pyx_n_s____author__, ((PyObject *)__pyx_kp_s_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2841 | 2842 | /* "cityhash.pyx":26 2843 | * 2844 | * __author__ = "Alexander [Amper] Marshalov" 2845 | * __email__ = "alone.amper+cityhash@gmail.com" # <<<<<<<<<<<<<< 2846 | * __all__ = ["CityHash64", 2847 | * "CityHash64WithSeed", 2848 | */ 2849 | if (PyObject_SetAttr(__pyx_m, __pyx_n_s____email__, ((PyObject *)__pyx_kp_s_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2850 | 2851 | /* "cityhash.pyx":27 2852 | * __author__ = "Alexander [Amper] Marshalov" 2853 | * __email__ = "alone.amper+cityhash@gmail.com" 2854 | * __all__ = ["CityHash64", # <<<<<<<<<<<<<< 2855 | * "CityHash64WithSeed", 2856 | * "CityHash64WithSeeds", 2857 | */ 2858 | __pyx_t_1 = PyList_New(8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2859 | __Pyx_GOTREF(((PyObject *)__pyx_t_1)); 2860 | __Pyx_INCREF(((PyObject *)__pyx_n_s__CityHash64)); 2861 | PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__CityHash64)); 2862 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CityHash64)); 2863 | __Pyx_INCREF(((PyObject *)__pyx_n_s__CityHash64WithSeed)); 2864 | PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__CityHash64WithSeed)); 2865 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CityHash64WithSeed)); 2866 | __Pyx_INCREF(((PyObject *)__pyx_n_s__CityHash64WithSeeds)); 2867 | PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__CityHash64WithSeeds)); 2868 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CityHash64WithSeeds)); 2869 | __Pyx_INCREF(((PyObject *)__pyx_n_s__CityHash128)); 2870 | PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__CityHash128)); 2871 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CityHash128)); 2872 | __Pyx_INCREF(((PyObject *)__pyx_n_s__CityHash128WithSeed)); 2873 | PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__CityHash128WithSeed)); 2874 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CityHash128WithSeed)); 2875 | __Pyx_INCREF(((PyObject *)__pyx_n_s__Hash128to64)); 2876 | PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__Hash128to64)); 2877 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Hash128to64)); 2878 | __Pyx_INCREF(((PyObject *)__pyx_n_s__ch64)); 2879 | PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__ch64)); 2880 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ch64)); 2881 | __Pyx_INCREF(((PyObject *)__pyx_n_s__ch128)); 2882 | PyList_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__ch128)); 2883 | __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ch128)); 2884 | if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2885 | __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; 2886 | 2887 | /* "cityhash.pyx":119 2888 | * cdef uint64 __value 2889 | * cdef public bytes name 2890 | * def __cinit__(self, bytes value=str("")): # <<<<<<<<<<<<<< 2891 | * self.name = str("CityHash64") 2892 | * self.update(value) 2893 | */ 2894 | __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2895 | __Pyx_GOTREF(__pyx_t_1); 2896 | if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2897 | __pyx_k_1 = ((PyObject*)__pyx_t_1); 2898 | __Pyx_GIVEREF(__pyx_t_1); 2899 | __pyx_t_1 = 0; 2900 | 2901 | /* "cityhash.pyx":133 2902 | * cdef tuple __value 2903 | * cdef public bytes name 2904 | * def __cinit__(self, bytes value=str("")): # <<<<<<<<<<<<<< 2905 | * self.name = str("CityHash128") 2906 | * self.update(value) 2907 | */ 2908 | __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2909 | __Pyx_GOTREF(__pyx_t_1); 2910 | if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2911 | __pyx_k_3 = ((PyObject*)__pyx_t_1); 2912 | __Pyx_GIVEREF(__pyx_t_1); 2913 | __pyx_t_1 = 0; 2914 | 2915 | /* "cityhash.pyx":1 2916 | * #cython: infer_types=True # <<<<<<<<<<<<<< 2917 | * 2918 | * """ 2919 | */ 2920 | __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2921 | __Pyx_GOTREF(((PyObject *)__pyx_t_1)); 2922 | if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 2923 | __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; 2924 | goto __pyx_L0; 2925 | __pyx_L1_error:; 2926 | __Pyx_XDECREF(__pyx_t_1); 2927 | if (__pyx_m) { 2928 | __Pyx_AddTraceback("init cityhash", __pyx_clineno, __pyx_lineno, __pyx_filename); 2929 | Py_DECREF(__pyx_m); __pyx_m = 0; 2930 | } else if (!PyErr_Occurred()) { 2931 | PyErr_SetString(PyExc_ImportError, "init cityhash"); 2932 | } 2933 | __pyx_L0:; 2934 | __Pyx_RefNannyFinishContext(); 2935 | #if PY_MAJOR_VERSION < 3 2936 | return; 2937 | #else 2938 | return __pyx_m; 2939 | #endif 2940 | } 2941 | 2942 | /* Runtime support code */ 2943 | 2944 | #if CYTHON_REFNANNY 2945 | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { 2946 | PyObject *m = NULL, *p = NULL; 2947 | void *r = NULL; 2948 | m = PyImport_ImportModule((char *)modname); 2949 | if (!m) goto end; 2950 | p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); 2951 | if (!p) goto end; 2952 | r = PyLong_AsVoidPtr(p); 2953 | end: 2954 | Py_XDECREF(p); 2955 | Py_XDECREF(m); 2956 | return (__Pyx_RefNannyAPIStruct *)r; 2957 | } 2958 | #endif /* CYTHON_REFNANNY */ 2959 | 2960 | static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, 2961 | const char *name, int exact) 2962 | { 2963 | if (!type) { 2964 | PyErr_Format(PyExc_SystemError, "Missing type object"); 2965 | return 0; 2966 | } 2967 | if (none_allowed && obj == Py_None) return 1; 2968 | else if (exact) { 2969 | if (Py_TYPE(obj) == type) return 1; 2970 | } 2971 | else { 2972 | if (PyObject_TypeCheck(obj, type)) return 1; 2973 | } 2974 | PyErr_Format(PyExc_TypeError, 2975 | "Argument '%s' has incorrect type (expected %s, got %s)", 2976 | name, type->tp_name, Py_TYPE(obj)->tp_name); 2977 | return 0; 2978 | } 2979 | 2980 | static void __Pyx_RaiseArgtupleInvalid( 2981 | const char* func_name, 2982 | int exact, 2983 | Py_ssize_t num_min, 2984 | Py_ssize_t num_max, 2985 | Py_ssize_t num_found) 2986 | { 2987 | Py_ssize_t num_expected; 2988 | const char *more_or_less; 2989 | 2990 | if (num_found < num_min) { 2991 | num_expected = num_min; 2992 | more_or_less = "at least"; 2993 | } else { 2994 | num_expected = num_max; 2995 | more_or_less = "at most"; 2996 | } 2997 | if (exact) { 2998 | more_or_less = "exactly"; 2999 | } 3000 | PyErr_Format(PyExc_TypeError, 3001 | "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)", 3002 | func_name, more_or_less, num_expected, 3003 | (num_expected == 1) ? "" : "s", num_found); 3004 | } 3005 | 3006 | static void __Pyx_RaiseDoubleKeywordsError( 3007 | const char* func_name, 3008 | PyObject* kw_name) 3009 | { 3010 | PyErr_Format(PyExc_TypeError, 3011 | #if PY_MAJOR_VERSION >= 3 3012 | "%s() got multiple values for keyword argument '%U'", func_name, kw_name); 3013 | #else 3014 | "%s() got multiple values for keyword argument '%s'", func_name, 3015 | PyString_AS_STRING(kw_name)); 3016 | #endif 3017 | } 3018 | 3019 | static int __Pyx_ParseOptionalKeywords( 3020 | PyObject *kwds, 3021 | PyObject **argnames[], 3022 | PyObject *kwds2, 3023 | PyObject *values[], 3024 | Py_ssize_t num_pos_args, 3025 | const char* function_name) 3026 | { 3027 | PyObject *key = 0, *value = 0; 3028 | Py_ssize_t pos = 0; 3029 | PyObject*** name; 3030 | PyObject*** first_kw_arg = argnames + num_pos_args; 3031 | 3032 | while (PyDict_Next(kwds, &pos, &key, &value)) { 3033 | name = first_kw_arg; 3034 | while (*name && (**name != key)) name++; 3035 | if (*name) { 3036 | values[name-argnames] = value; 3037 | } else { 3038 | #if PY_MAJOR_VERSION < 3 3039 | if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { 3040 | #else 3041 | if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) { 3042 | #endif 3043 | goto invalid_keyword_type; 3044 | } else { 3045 | for (name = first_kw_arg; *name; name++) { 3046 | #if PY_MAJOR_VERSION >= 3 3047 | if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && 3048 | PyUnicode_Compare(**name, key) == 0) break; 3049 | #else 3050 | if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && 3051 | _PyString_Eq(**name, key)) break; 3052 | #endif 3053 | } 3054 | if (*name) { 3055 | values[name-argnames] = value; 3056 | } else { 3057 | /* unexpected keyword found */ 3058 | for (name=argnames; name != first_kw_arg; name++) { 3059 | if (**name == key) goto arg_passed_twice; 3060 | #if PY_MAJOR_VERSION >= 3 3061 | if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && 3062 | PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice; 3063 | #else 3064 | if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && 3065 | _PyString_Eq(**name, key)) goto arg_passed_twice; 3066 | #endif 3067 | } 3068 | if (kwds2) { 3069 | if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; 3070 | } else { 3071 | goto invalid_keyword; 3072 | } 3073 | } 3074 | } 3075 | } 3076 | } 3077 | return 0; 3078 | arg_passed_twice: 3079 | __Pyx_RaiseDoubleKeywordsError(function_name, **name); 3080 | goto bad; 3081 | invalid_keyword_type: 3082 | PyErr_Format(PyExc_TypeError, 3083 | "%s() keywords must be strings", function_name); 3084 | goto bad; 3085 | invalid_keyword: 3086 | PyErr_Format(PyExc_TypeError, 3087 | #if PY_MAJOR_VERSION < 3 3088 | "%s() got an unexpected keyword argument '%s'", 3089 | function_name, PyString_AsString(key)); 3090 | #else 3091 | "%s() got an unexpected keyword argument '%U'", 3092 | function_name, key); 3093 | #endif 3094 | bad: 3095 | return -1; 3096 | } 3097 | 3098 | 3099 | static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t val) { 3100 | const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0; 3101 | const int is_unsigned = const_zero < neg_one; 3102 | if ((sizeof(uint64_t) == sizeof(char)) || 3103 | (sizeof(uint64_t) == sizeof(short))) { 3104 | return PyInt_FromLong((long)val); 3105 | } else if ((sizeof(uint64_t) == sizeof(int)) || 3106 | (sizeof(uint64_t) == sizeof(long))) { 3107 | if (is_unsigned) 3108 | return PyLong_FromUnsignedLong((unsigned long)val); 3109 | else 3110 | return PyInt_FromLong((long)val); 3111 | } else if (sizeof(uint64_t) == sizeof(PY_LONG_LONG)) { 3112 | if (is_unsigned) 3113 | return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val); 3114 | else 3115 | return PyLong_FromLongLong((PY_LONG_LONG)val); 3116 | } else { 3117 | int one = 1; int little = (int)*(unsigned char *)&one; 3118 | unsigned char *bytes = (unsigned char *)&val; 3119 | return _PyLong_FromByteArray(bytes, sizeof(uint64_t), 3120 | little, !is_unsigned); 3121 | } 3122 | } 3123 | 3124 | static CYTHON_INLINE uint64_t __Pyx_PyInt_from_py_uint64_t(PyObject* x) { 3125 | const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0; 3126 | const int is_unsigned = const_zero < neg_one; 3127 | if (sizeof(uint64_t) == sizeof(char)) { 3128 | if (is_unsigned) 3129 | return (uint64_t)__Pyx_PyInt_AsUnsignedChar(x); 3130 | else 3131 | return (uint64_t)__Pyx_PyInt_AsSignedChar(x); 3132 | } else if (sizeof(uint64_t) == sizeof(short)) { 3133 | if (is_unsigned) 3134 | return (uint64_t)__Pyx_PyInt_AsUnsignedShort(x); 3135 | else 3136 | return (uint64_t)__Pyx_PyInt_AsSignedShort(x); 3137 | } else if (sizeof(uint64_t) == sizeof(int)) { 3138 | if (is_unsigned) 3139 | return (uint64_t)__Pyx_PyInt_AsUnsignedInt(x); 3140 | else 3141 | return (uint64_t)__Pyx_PyInt_AsSignedInt(x); 3142 | } else if (sizeof(uint64_t) == sizeof(long)) { 3143 | if (is_unsigned) 3144 | return (uint64_t)__Pyx_PyInt_AsUnsignedLong(x); 3145 | else 3146 | return (uint64_t)__Pyx_PyInt_AsSignedLong(x); 3147 | } else if (sizeof(uint64_t) == sizeof(PY_LONG_LONG)) { 3148 | if (is_unsigned) 3149 | return (uint64_t)__Pyx_PyInt_AsUnsignedLongLong(x); 3150 | else 3151 | return (uint64_t)__Pyx_PyInt_AsSignedLongLong(x); 3152 | } else { 3153 | uint64_t val; 3154 | PyObject *v = __Pyx_PyNumber_Int(x); 3155 | #if PY_VERSION_HEX < 0x03000000 3156 | if (likely(v) && !PyLong_Check(v)) { 3157 | PyObject *tmp = v; 3158 | v = PyNumber_Long(tmp); 3159 | Py_DECREF(tmp); 3160 | } 3161 | #endif 3162 | if (likely(v)) { 3163 | int one = 1; int is_little = (int)*(unsigned char *)&one; 3164 | unsigned char *bytes = (unsigned char *)&val; 3165 | int ret = _PyLong_AsByteArray((PyLongObject *)v, 3166 | bytes, sizeof(val), 3167 | is_little, !is_unsigned); 3168 | Py_DECREF(v); 3169 | if (likely(!ret)) 3170 | return val; 3171 | } 3172 | return (uint64_t)-1; 3173 | } 3174 | } 3175 | 3176 | static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { 3177 | const unsigned char neg_one = (unsigned char)-1, const_zero = 0; 3178 | const int is_unsigned = neg_one > const_zero; 3179 | if (sizeof(unsigned char) < sizeof(long)) { 3180 | long val = __Pyx_PyInt_AsLong(x); 3181 | if (unlikely(val != (long)(unsigned char)val)) { 3182 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3183 | PyErr_SetString(PyExc_OverflowError, 3184 | (is_unsigned && unlikely(val < 0)) ? 3185 | "can't convert negative value to unsigned char" : 3186 | "value too large to convert to unsigned char"); 3187 | } 3188 | return (unsigned char)-1; 3189 | } 3190 | return (unsigned char)val; 3191 | } 3192 | return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); 3193 | } 3194 | 3195 | static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { 3196 | const unsigned short neg_one = (unsigned short)-1, const_zero = 0; 3197 | const int is_unsigned = neg_one > const_zero; 3198 | if (sizeof(unsigned short) < sizeof(long)) { 3199 | long val = __Pyx_PyInt_AsLong(x); 3200 | if (unlikely(val != (long)(unsigned short)val)) { 3201 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3202 | PyErr_SetString(PyExc_OverflowError, 3203 | (is_unsigned && unlikely(val < 0)) ? 3204 | "can't convert negative value to unsigned short" : 3205 | "value too large to convert to unsigned short"); 3206 | } 3207 | return (unsigned short)-1; 3208 | } 3209 | return (unsigned short)val; 3210 | } 3211 | return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); 3212 | } 3213 | 3214 | static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { 3215 | const unsigned int neg_one = (unsigned int)-1, const_zero = 0; 3216 | const int is_unsigned = neg_one > const_zero; 3217 | if (sizeof(unsigned int) < sizeof(long)) { 3218 | long val = __Pyx_PyInt_AsLong(x); 3219 | if (unlikely(val != (long)(unsigned int)val)) { 3220 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3221 | PyErr_SetString(PyExc_OverflowError, 3222 | (is_unsigned && unlikely(val < 0)) ? 3223 | "can't convert negative value to unsigned int" : 3224 | "value too large to convert to unsigned int"); 3225 | } 3226 | return (unsigned int)-1; 3227 | } 3228 | return (unsigned int)val; 3229 | } 3230 | return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); 3231 | } 3232 | 3233 | static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { 3234 | const char neg_one = (char)-1, const_zero = 0; 3235 | const int is_unsigned = neg_one > const_zero; 3236 | if (sizeof(char) < sizeof(long)) { 3237 | long val = __Pyx_PyInt_AsLong(x); 3238 | if (unlikely(val != (long)(char)val)) { 3239 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3240 | PyErr_SetString(PyExc_OverflowError, 3241 | (is_unsigned && unlikely(val < 0)) ? 3242 | "can't convert negative value to char" : 3243 | "value too large to convert to char"); 3244 | } 3245 | return (char)-1; 3246 | } 3247 | return (char)val; 3248 | } 3249 | return (char)__Pyx_PyInt_AsLong(x); 3250 | } 3251 | 3252 | static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { 3253 | const short neg_one = (short)-1, const_zero = 0; 3254 | const int is_unsigned = neg_one > const_zero; 3255 | if (sizeof(short) < sizeof(long)) { 3256 | long val = __Pyx_PyInt_AsLong(x); 3257 | if (unlikely(val != (long)(short)val)) { 3258 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3259 | PyErr_SetString(PyExc_OverflowError, 3260 | (is_unsigned && unlikely(val < 0)) ? 3261 | "can't convert negative value to short" : 3262 | "value too large to convert to short"); 3263 | } 3264 | return (short)-1; 3265 | } 3266 | return (short)val; 3267 | } 3268 | return (short)__Pyx_PyInt_AsLong(x); 3269 | } 3270 | 3271 | static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { 3272 | const int neg_one = (int)-1, const_zero = 0; 3273 | const int is_unsigned = neg_one > const_zero; 3274 | if (sizeof(int) < sizeof(long)) { 3275 | long val = __Pyx_PyInt_AsLong(x); 3276 | if (unlikely(val != (long)(int)val)) { 3277 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3278 | PyErr_SetString(PyExc_OverflowError, 3279 | (is_unsigned && unlikely(val < 0)) ? 3280 | "can't convert negative value to int" : 3281 | "value too large to convert to int"); 3282 | } 3283 | return (int)-1; 3284 | } 3285 | return (int)val; 3286 | } 3287 | return (int)__Pyx_PyInt_AsLong(x); 3288 | } 3289 | 3290 | static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { 3291 | const signed char neg_one = (signed char)-1, const_zero = 0; 3292 | const int is_unsigned = neg_one > const_zero; 3293 | if (sizeof(signed char) < sizeof(long)) { 3294 | long val = __Pyx_PyInt_AsLong(x); 3295 | if (unlikely(val != (long)(signed char)val)) { 3296 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3297 | PyErr_SetString(PyExc_OverflowError, 3298 | (is_unsigned && unlikely(val < 0)) ? 3299 | "can't convert negative value to signed char" : 3300 | "value too large to convert to signed char"); 3301 | } 3302 | return (signed char)-1; 3303 | } 3304 | return (signed char)val; 3305 | } 3306 | return (signed char)__Pyx_PyInt_AsSignedLong(x); 3307 | } 3308 | 3309 | static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { 3310 | const signed short neg_one = (signed short)-1, const_zero = 0; 3311 | const int is_unsigned = neg_one > const_zero; 3312 | if (sizeof(signed short) < sizeof(long)) { 3313 | long val = __Pyx_PyInt_AsLong(x); 3314 | if (unlikely(val != (long)(signed short)val)) { 3315 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3316 | PyErr_SetString(PyExc_OverflowError, 3317 | (is_unsigned && unlikely(val < 0)) ? 3318 | "can't convert negative value to signed short" : 3319 | "value too large to convert to signed short"); 3320 | } 3321 | return (signed short)-1; 3322 | } 3323 | return (signed short)val; 3324 | } 3325 | return (signed short)__Pyx_PyInt_AsSignedLong(x); 3326 | } 3327 | 3328 | static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { 3329 | const signed int neg_one = (signed int)-1, const_zero = 0; 3330 | const int is_unsigned = neg_one > const_zero; 3331 | if (sizeof(signed int) < sizeof(long)) { 3332 | long val = __Pyx_PyInt_AsLong(x); 3333 | if (unlikely(val != (long)(signed int)val)) { 3334 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3335 | PyErr_SetString(PyExc_OverflowError, 3336 | (is_unsigned && unlikely(val < 0)) ? 3337 | "can't convert negative value to signed int" : 3338 | "value too large to convert to signed int"); 3339 | } 3340 | return (signed int)-1; 3341 | } 3342 | return (signed int)val; 3343 | } 3344 | return (signed int)__Pyx_PyInt_AsSignedLong(x); 3345 | } 3346 | 3347 | static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { 3348 | const int neg_one = (int)-1, const_zero = 0; 3349 | const int is_unsigned = neg_one > const_zero; 3350 | if (sizeof(int) < sizeof(long)) { 3351 | long val = __Pyx_PyInt_AsLong(x); 3352 | if (unlikely(val != (long)(int)val)) { 3353 | if (!unlikely(val == -1 && PyErr_Occurred())) { 3354 | PyErr_SetString(PyExc_OverflowError, 3355 | (is_unsigned && unlikely(val < 0)) ? 3356 | "can't convert negative value to int" : 3357 | "value too large to convert to int"); 3358 | } 3359 | return (int)-1; 3360 | } 3361 | return (int)val; 3362 | } 3363 | return (int)__Pyx_PyInt_AsLong(x); 3364 | } 3365 | 3366 | static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { 3367 | const unsigned long neg_one = (unsigned long)-1, const_zero = 0; 3368 | const int is_unsigned = neg_one > const_zero; 3369 | #if PY_VERSION_HEX < 0x03000000 3370 | if (likely(PyInt_Check(x))) { 3371 | long val = PyInt_AS_LONG(x); 3372 | if (is_unsigned && unlikely(val < 0)) { 3373 | PyErr_SetString(PyExc_OverflowError, 3374 | "can't convert negative value to unsigned long"); 3375 | return (unsigned long)-1; 3376 | } 3377 | return (unsigned long)val; 3378 | } else 3379 | #endif 3380 | if (likely(PyLong_Check(x))) { 3381 | if (is_unsigned) { 3382 | if (unlikely(Py_SIZE(x) < 0)) { 3383 | PyErr_SetString(PyExc_OverflowError, 3384 | "can't convert negative value to unsigned long"); 3385 | return (unsigned long)-1; 3386 | } 3387 | return (unsigned long)PyLong_AsUnsignedLong(x); 3388 | } else { 3389 | return (unsigned long)PyLong_AsLong(x); 3390 | } 3391 | } else { 3392 | unsigned long val; 3393 | PyObject *tmp = __Pyx_PyNumber_Int(x); 3394 | if (!tmp) return (unsigned long)-1; 3395 | val = __Pyx_PyInt_AsUnsignedLong(tmp); 3396 | Py_DECREF(tmp); 3397 | return val; 3398 | } 3399 | } 3400 | 3401 | static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { 3402 | const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; 3403 | const int is_unsigned = neg_one > const_zero; 3404 | #if PY_VERSION_HEX < 0x03000000 3405 | if (likely(PyInt_Check(x))) { 3406 | long val = PyInt_AS_LONG(x); 3407 | if (is_unsigned && unlikely(val < 0)) { 3408 | PyErr_SetString(PyExc_OverflowError, 3409 | "can't convert negative value to unsigned PY_LONG_LONG"); 3410 | return (unsigned PY_LONG_LONG)-1; 3411 | } 3412 | return (unsigned PY_LONG_LONG)val; 3413 | } else 3414 | #endif 3415 | if (likely(PyLong_Check(x))) { 3416 | if (is_unsigned) { 3417 | if (unlikely(Py_SIZE(x) < 0)) { 3418 | PyErr_SetString(PyExc_OverflowError, 3419 | "can't convert negative value to unsigned PY_LONG_LONG"); 3420 | return (unsigned PY_LONG_LONG)-1; 3421 | } 3422 | return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); 3423 | } else { 3424 | return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); 3425 | } 3426 | } else { 3427 | unsigned PY_LONG_LONG val; 3428 | PyObject *tmp = __Pyx_PyNumber_Int(x); 3429 | if (!tmp) return (unsigned PY_LONG_LONG)-1; 3430 | val = __Pyx_PyInt_AsUnsignedLongLong(tmp); 3431 | Py_DECREF(tmp); 3432 | return val; 3433 | } 3434 | } 3435 | 3436 | static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { 3437 | const long neg_one = (long)-1, const_zero = 0; 3438 | const int is_unsigned = neg_one > const_zero; 3439 | #if PY_VERSION_HEX < 0x03000000 3440 | if (likely(PyInt_Check(x))) { 3441 | long val = PyInt_AS_LONG(x); 3442 | if (is_unsigned && unlikely(val < 0)) { 3443 | PyErr_SetString(PyExc_OverflowError, 3444 | "can't convert negative value to long"); 3445 | return (long)-1; 3446 | } 3447 | return (long)val; 3448 | } else 3449 | #endif 3450 | if (likely(PyLong_Check(x))) { 3451 | if (is_unsigned) { 3452 | if (unlikely(Py_SIZE(x) < 0)) { 3453 | PyErr_SetString(PyExc_OverflowError, 3454 | "can't convert negative value to long"); 3455 | return (long)-1; 3456 | } 3457 | return (long)PyLong_AsUnsignedLong(x); 3458 | } else { 3459 | return (long)PyLong_AsLong(x); 3460 | } 3461 | } else { 3462 | long val; 3463 | PyObject *tmp = __Pyx_PyNumber_Int(x); 3464 | if (!tmp) return (long)-1; 3465 | val = __Pyx_PyInt_AsLong(tmp); 3466 | Py_DECREF(tmp); 3467 | return val; 3468 | } 3469 | } 3470 | 3471 | static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { 3472 | const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; 3473 | const int is_unsigned = neg_one > const_zero; 3474 | #if PY_VERSION_HEX < 0x03000000 3475 | if (likely(PyInt_Check(x))) { 3476 | long val = PyInt_AS_LONG(x); 3477 | if (is_unsigned && unlikely(val < 0)) { 3478 | PyErr_SetString(PyExc_OverflowError, 3479 | "can't convert negative value to PY_LONG_LONG"); 3480 | return (PY_LONG_LONG)-1; 3481 | } 3482 | return (PY_LONG_LONG)val; 3483 | } else 3484 | #endif 3485 | if (likely(PyLong_Check(x))) { 3486 | if (is_unsigned) { 3487 | if (unlikely(Py_SIZE(x) < 0)) { 3488 | PyErr_SetString(PyExc_OverflowError, 3489 | "can't convert negative value to PY_LONG_LONG"); 3490 | return (PY_LONG_LONG)-1; 3491 | } 3492 | return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); 3493 | } else { 3494 | return (PY_LONG_LONG)PyLong_AsLongLong(x); 3495 | } 3496 | } else { 3497 | PY_LONG_LONG val; 3498 | PyObject *tmp = __Pyx_PyNumber_Int(x); 3499 | if (!tmp) return (PY_LONG_LONG)-1; 3500 | val = __Pyx_PyInt_AsLongLong(tmp); 3501 | Py_DECREF(tmp); 3502 | return val; 3503 | } 3504 | } 3505 | 3506 | static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { 3507 | const signed long neg_one = (signed long)-1, const_zero = 0; 3508 | const int is_unsigned = neg_one > const_zero; 3509 | #if PY_VERSION_HEX < 0x03000000 3510 | if (likely(PyInt_Check(x))) { 3511 | long val = PyInt_AS_LONG(x); 3512 | if (is_unsigned && unlikely(val < 0)) { 3513 | PyErr_SetString(PyExc_OverflowError, 3514 | "can't convert negative value to signed long"); 3515 | return (signed long)-1; 3516 | } 3517 | return (signed long)val; 3518 | } else 3519 | #endif 3520 | if (likely(PyLong_Check(x))) { 3521 | if (is_unsigned) { 3522 | if (unlikely(Py_SIZE(x) < 0)) { 3523 | PyErr_SetString(PyExc_OverflowError, 3524 | "can't convert negative value to signed long"); 3525 | return (signed long)-1; 3526 | } 3527 | return (signed long)PyLong_AsUnsignedLong(x); 3528 | } else { 3529 | return (signed long)PyLong_AsLong(x); 3530 | } 3531 | } else { 3532 | signed long val; 3533 | PyObject *tmp = __Pyx_PyNumber_Int(x); 3534 | if (!tmp) return (signed long)-1; 3535 | val = __Pyx_PyInt_AsSignedLong(tmp); 3536 | Py_DECREF(tmp); 3537 | return val; 3538 | } 3539 | } 3540 | 3541 | static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { 3542 | const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; 3543 | const int is_unsigned = neg_one > const_zero; 3544 | #if PY_VERSION_HEX < 0x03000000 3545 | if (likely(PyInt_Check(x))) { 3546 | long val = PyInt_AS_LONG(x); 3547 | if (is_unsigned && unlikely(val < 0)) { 3548 | PyErr_SetString(PyExc_OverflowError, 3549 | "can't convert negative value to signed PY_LONG_LONG"); 3550 | return (signed PY_LONG_LONG)-1; 3551 | } 3552 | return (signed PY_LONG_LONG)val; 3553 | } else 3554 | #endif 3555 | if (likely(PyLong_Check(x))) { 3556 | if (is_unsigned) { 3557 | if (unlikely(Py_SIZE(x) < 0)) { 3558 | PyErr_SetString(PyExc_OverflowError, 3559 | "can't convert negative value to signed PY_LONG_LONG"); 3560 | return (signed PY_LONG_LONG)-1; 3561 | } 3562 | return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); 3563 | } else { 3564 | return (signed PY_LONG_LONG)PyLong_AsLongLong(x); 3565 | } 3566 | } else { 3567 | signed PY_LONG_LONG val; 3568 | PyObject *tmp = __Pyx_PyNumber_Int(x); 3569 | if (!tmp) return (signed PY_LONG_LONG)-1; 3570 | val = __Pyx_PyInt_AsSignedLongLong(tmp); 3571 | Py_DECREF(tmp); 3572 | return val; 3573 | } 3574 | } 3575 | 3576 | static int __Pyx_check_binary_version(void) { 3577 | char ctversion[4], rtversion[4]; 3578 | PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); 3579 | PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); 3580 | if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { 3581 | char message[200]; 3582 | PyOS_snprintf(message, sizeof(message), 3583 | "compiletime version %s of module '%.100s' " 3584 | "does not match runtime version %s", 3585 | ctversion, __Pyx_MODULE_NAME, rtversion); 3586 | #if PY_VERSION_HEX < 0x02050000 3587 | return PyErr_Warn(NULL, message); 3588 | #else 3589 | return PyErr_WarnEx(NULL, message, 1); 3590 | #endif 3591 | } 3592 | return 0; 3593 | } 3594 | 3595 | static int __Pyx_SetVtable(PyObject *dict, void *vtable) { 3596 | #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) 3597 | PyObject *ob = PyCapsule_New(vtable, 0, 0); 3598 | #else 3599 | PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); 3600 | #endif 3601 | if (!ob) 3602 | goto bad; 3603 | if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0) 3604 | goto bad; 3605 | Py_DECREF(ob); 3606 | return 0; 3607 | bad: 3608 | Py_XDECREF(ob); 3609 | return -1; 3610 | } 3611 | 3612 | #include "compile.h" 3613 | #include "frameobject.h" 3614 | #include "traceback.h" 3615 | 3616 | static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno, 3617 | int __pyx_lineno, const char *__pyx_filename) { 3618 | PyObject *py_srcfile = 0; 3619 | PyObject *py_funcname = 0; 3620 | PyObject *py_globals = 0; 3621 | PyCodeObject *py_code = 0; 3622 | PyFrameObject *py_frame = 0; 3623 | 3624 | #if PY_MAJOR_VERSION < 3 3625 | py_srcfile = PyString_FromString(__pyx_filename); 3626 | #else 3627 | py_srcfile = PyUnicode_FromString(__pyx_filename); 3628 | #endif 3629 | if (!py_srcfile) goto bad; 3630 | if (__pyx_clineno) { 3631 | #if PY_MAJOR_VERSION < 3 3632 | py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); 3633 | #else 3634 | py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); 3635 | #endif 3636 | } 3637 | else { 3638 | #if PY_MAJOR_VERSION < 3 3639 | py_funcname = PyString_FromString(funcname); 3640 | #else 3641 | py_funcname = PyUnicode_FromString(funcname); 3642 | #endif 3643 | } 3644 | if (!py_funcname) goto bad; 3645 | py_globals = PyModule_GetDict(__pyx_m); 3646 | if (!py_globals) goto bad; 3647 | py_code = PyCode_New( 3648 | 0, /*int argcount,*/ 3649 | #if PY_MAJOR_VERSION >= 3 3650 | 0, /*int kwonlyargcount,*/ 3651 | #endif 3652 | 0, /*int nlocals,*/ 3653 | 0, /*int stacksize,*/ 3654 | 0, /*int flags,*/ 3655 | __pyx_empty_bytes, /*PyObject *code,*/ 3656 | __pyx_empty_tuple, /*PyObject *consts,*/ 3657 | __pyx_empty_tuple, /*PyObject *names,*/ 3658 | __pyx_empty_tuple, /*PyObject *varnames,*/ 3659 | __pyx_empty_tuple, /*PyObject *freevars,*/ 3660 | __pyx_empty_tuple, /*PyObject *cellvars,*/ 3661 | py_srcfile, /*PyObject *filename,*/ 3662 | py_funcname, /*PyObject *name,*/ 3663 | __pyx_lineno, /*int firstlineno,*/ 3664 | __pyx_empty_bytes /*PyObject *lnotab*/ 3665 | ); 3666 | if (!py_code) goto bad; 3667 | py_frame = PyFrame_New( 3668 | PyThreadState_GET(), /*PyThreadState *tstate,*/ 3669 | py_code, /*PyCodeObject *code,*/ 3670 | py_globals, /*PyObject *globals,*/ 3671 | 0 /*PyObject *locals*/ 3672 | ); 3673 | if (!py_frame) goto bad; 3674 | py_frame->f_lineno = __pyx_lineno; 3675 | PyTraceBack_Here(py_frame); 3676 | bad: 3677 | Py_XDECREF(py_srcfile); 3678 | Py_XDECREF(py_funcname); 3679 | Py_XDECREF(py_code); 3680 | Py_XDECREF(py_frame); 3681 | } 3682 | 3683 | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { 3684 | while (t->p) { 3685 | #if PY_MAJOR_VERSION < 3 3686 | if (t->is_unicode) { 3687 | *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); 3688 | } else if (t->intern) { 3689 | *t->p = PyString_InternFromString(t->s); 3690 | } else { 3691 | *t->p = PyString_FromStringAndSize(t->s, t->n - 1); 3692 | } 3693 | #else /* Python 3+ has unicode identifiers */ 3694 | if (t->is_unicode | t->is_str) { 3695 | if (t->intern) { 3696 | *t->p = PyUnicode_InternFromString(t->s); 3697 | } else if (t->encoding) { 3698 | *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); 3699 | } else { 3700 | *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); 3701 | } 3702 | } else { 3703 | *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); 3704 | } 3705 | #endif 3706 | if (!*t->p) 3707 | return -1; 3708 | ++t; 3709 | } 3710 | return 0; 3711 | } 3712 | 3713 | /* Type Conversion Functions */ 3714 | 3715 | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { 3716 | int is_true = x == Py_True; 3717 | if (is_true | (x == Py_False) | (x == Py_None)) return is_true; 3718 | else return PyObject_IsTrue(x); 3719 | } 3720 | 3721 | static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { 3722 | PyNumberMethods *m; 3723 | const char *name = NULL; 3724 | PyObject *res = NULL; 3725 | #if PY_VERSION_HEX < 0x03000000 3726 | if (PyInt_Check(x) || PyLong_Check(x)) 3727 | #else 3728 | if (PyLong_Check(x)) 3729 | #endif 3730 | return Py_INCREF(x), x; 3731 | m = Py_TYPE(x)->tp_as_number; 3732 | #if PY_VERSION_HEX < 0x03000000 3733 | if (m && m->nb_int) { 3734 | name = "int"; 3735 | res = PyNumber_Int(x); 3736 | } 3737 | else if (m && m->nb_long) { 3738 | name = "long"; 3739 | res = PyNumber_Long(x); 3740 | } 3741 | #else 3742 | if (m && m->nb_int) { 3743 | name = "int"; 3744 | res = PyNumber_Long(x); 3745 | } 3746 | #endif 3747 | if (res) { 3748 | #if PY_VERSION_HEX < 0x03000000 3749 | if (!PyInt_Check(res) && !PyLong_Check(res)) { 3750 | #else 3751 | if (!PyLong_Check(res)) { 3752 | #endif 3753 | PyErr_Format(PyExc_TypeError, 3754 | "__%s__ returned non-%s (type %.200s)", 3755 | name, name, Py_TYPE(res)->tp_name); 3756 | Py_DECREF(res); 3757 | return NULL; 3758 | } 3759 | } 3760 | else if (!PyErr_Occurred()) { 3761 | PyErr_SetString(PyExc_TypeError, 3762 | "an integer is required"); 3763 | } 3764 | return res; 3765 | } 3766 | 3767 | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { 3768 | Py_ssize_t ival; 3769 | PyObject* x = PyNumber_Index(b); 3770 | if (!x) return -1; 3771 | ival = PyInt_AsSsize_t(x); 3772 | Py_DECREF(x); 3773 | return ival; 3774 | } 3775 | 3776 | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { 3777 | #if PY_VERSION_HEX < 0x02050000 3778 | if (ival <= LONG_MAX) 3779 | return PyInt_FromLong((long)ival); 3780 | else { 3781 | unsigned char *bytes = (unsigned char *) &ival; 3782 | int one = 1; int little = (int)*(unsigned char*)&one; 3783 | return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); 3784 | } 3785 | #else 3786 | return PyInt_FromSize_t(ival); 3787 | #endif 3788 | } 3789 | 3790 | static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { 3791 | unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); 3792 | if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) { 3793 | return (size_t)-1; 3794 | } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { 3795 | PyErr_SetString(PyExc_OverflowError, 3796 | "value too large to convert to size_t"); 3797 | return (size_t)-1; 3798 | } 3799 | return (size_t)val; 3800 | } 3801 | 3802 | 3803 | #endif /* Py_PYTHON_H */ 3804 | -------------------------------------------------------------------------------- /cityhash.pyx: -------------------------------------------------------------------------------- 1 | #cython: infer_types=True 2 | 3 | """ 4 | Copyright (c) 2011 Alexander [Amper] Marshalov 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | """ 24 | 25 | __author__ = "Alexander [Amper] Marshalov" 26 | __email__ = "alone.amper+cityhash@gmail.com" 27 | __all__ = ["CityHash64", 28 | "CityHash64WithSeed", 29 | "CityHash64WithSeeds", 30 | "CityHash128", 31 | "CityHash128WithSeed", 32 | "Hash128to64", 33 | "ch64", 34 | "ch128", 35 | ] 36 | 37 | cdef extern from * nogil: 38 | ctypedef unsigned long int uint32_t 39 | ctypedef unsigned long long int uint64_t 40 | 41 | cdef extern from "city.h" nogil: 42 | ctypedef uint32_t uint32 43 | ctypedef uint64_t uint64 44 | 45 | cdef extern from "" namespace "std": 46 | cdef cppclass pair[T, U]: 47 | T first 48 | U second 49 | pair() 50 | pair(pair&) 51 | pair(T&, U&) 52 | bint operator == (pair&, pair&) 53 | bint operator != (pair&, pair&) 54 | bint operator < (pair&, pair&) 55 | bint operator > (pair&, pair&) 56 | bint operator <= (pair&, pair&) 57 | bint operator >= (pair&, pair&) 58 | 59 | cdef extern from "city.h" nogil: 60 | ctypedef pair uint128 61 | cdef uint64 c_Uint128Low64 "Uint128Low64" (uint128& x) 62 | cdef uint64 c_Uint128High64 "Uint128High64" (uint128& x) 63 | cdef uint64 c_CityHash64 "CityHash64" (char *buf, size_t len) 64 | cdef uint64 c_CityHash64WithSeed "CityHash64WithSeed" (char *buf, size_t len, uint64 seed) 65 | cdef uint64 c_CityHash64WithSeeds "CityHash64WithSeeds" (char *buf, size_t len, uint64 seed0, uint64 seed1) 66 | cdef uint64 c_Hash128to64 "Hash128to64" (uint128[uint64,uint64]& x) 67 | cdef uint128[uint64,uint64] c_CityHash128 "CityHash128" (char *s, size_t len) 68 | cdef uint128[uint64,uint64] c_CityHash128WithSeed "CityHash128WithSeed" (char *s, size_t len, uint128[uint64,uint64] seed) 69 | 70 | cpdef CityHash64(bytes buf): 71 | """ 72 | Description: Hash function for a byte array. 73 | """ 74 | return c_CityHash64(buf, len(buf)) 75 | 76 | cpdef CityHash64WithSeed(bytes buf, uint64 seed): 77 | """ 78 | Description: Hash function for a byte array. For convenience, a 64-bit seed is also 79 | hashed into the result. 80 | """ 81 | return c_CityHash64WithSeed(buf, len(buf), seed) 82 | 83 | cpdef CityHash64WithSeeds(bytes buf, uint64 seed0, uint64 seed1): 84 | """ 85 | Description: Hash function for a byte array. For convenience, two seeds are also 86 | hashed into the result. 87 | """ 88 | return c_CityHash64WithSeeds(buf, len(buf), seed0, seed1) 89 | 90 | cpdef CityHash128(bytes buf): 91 | """ 92 | Description: Hash function for a byte array. 93 | """ 94 | cdef pair[uint64,uint64] result = c_CityHash128(buf, len(buf)) 95 | return (result.first, result.second) 96 | 97 | cpdef CityHash128WithSeed(bytes buf, tuple seed): 98 | """ 99 | Description: Hash function for a byte array. For convenience, a 128-bit seed is also 100 | hashed into the result. 101 | """ 102 | cdef pair[uint64,uint64] tseed 103 | tseed.first, tseed.second = seed[0], seed[1] 104 | cdef pair[uint64,uint64] result = c_CityHash128WithSeed(buf, len(buf), tseed) 105 | return (result.first, result.second) 106 | 107 | cpdef Hash128to64(tuple x): 108 | """ 109 | Description: Hash 128 input bits down to 64 bits of output. 110 | This is intended to be a reasonably good hash function. 111 | """ 112 | cdef pair[uint64,uint64] xx 113 | xx.first, xx.second = x[0], x[1] 114 | return c_Hash128to64(xx) 115 | 116 | cdef class ch64: 117 | cdef uint64 __value 118 | cdef public bytes name 119 | def __cinit__(self, bytes value=str("")): 120 | self.name = str("CityHash64") 121 | self.update(value) 122 | cpdef update(self, bytes value): 123 | if self.__value: 124 | self.__value = c_CityHash64WithSeed(value, len(value), self.__value) 125 | else: 126 | self.__value = c_CityHash64(value, len(value)) 127 | cpdef digest(self): 128 | return self.__value 129 | 130 | cdef class ch128: 131 | cdef tuple __value 132 | cdef public bytes name 133 | def __cinit__(self, bytes value=str("")): 134 | self.name = str("CityHash128") 135 | self.update(value) 136 | cpdef update(self, bytes value): 137 | if self.__value: 138 | self.__value = CityHash128WithSeed(value, self.__value) 139 | else: 140 | self.__value = CityHash128(value) 141 | cpdef digest(self): 142 | return self.__value 143 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Copyright (c) 2011 Alexander [Amper] Marshalov 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | """ 24 | 25 | __author__ = "Alexander [Amper] Marshalov" 26 | __email__ = "alone.amper+cityhash@gmail.com" 27 | __icq__ = "87-555-3" 28 | __jabber__ = "alone.amper@gmail.com" 29 | __twitter__ = "amper" 30 | __url__ = "http://amper.github.com/cityhash" 31 | 32 | from distutils.core import setup 33 | from distutils.extension import Extension 34 | 35 | ext_modules = [Extension("cityhash", ["city.cc","cityhash.cpp"])] 36 | 37 | setup( 38 | version = "0.0.2", 39 | description = "Python-bindings for CityHash", 40 | author = "Alexander [Amper] Marshalov", 41 | author_email = "alone.amper+cityhash@gmail.com", 42 | url = "https://github.com/Amper/cityhash", 43 | name='cityhash', 44 | license='MIT', 45 | ext_modules = ext_modules) 46 | --------------------------------------------------------------------------------