Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit 6788a72

Browse files
committed
Merge branch 'master' into 10/get-many
2 parents 7eba526 + 6145090 commit 6788a72

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

arraymap.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,15 @@ char_get_end_p(char* p, Py_ssize_t dt_size) {
184184
}
185185

186186

187+
// This masks the input with INT64_MAX, which removes the MSB; we then cast to an int64; the range is now between 0 and INT64_MAX. We then use the MSB of the original value; if set, we negate the number, producing negative values for the upper half of the uint64 range. Note that we only need to check for hash -1 in this branch.
187188
static inline Py_hash_t
188189
uint_to_hash(npy_uint64 v) {
189-
Py_hash_t hash = (Py_hash_t)(v >> 1); // half unsigned fits in signed
190-
if (hash == -1) {
191-
return -2;
190+
Py_hash_t hash = (Py_hash_t)(v & INT64_MAX);
191+
if (v >> 63) {
192+
hash = -hash;
193+
if (hash == -1) {
194+
return -2;
195+
}
192196
}
193197
return hash;
194198
}

doc/articles/npy-opt.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,20 @@ def get_array(size: int) -> np.ndarray:
309309
return array
310310

311311

312+
class FFUInt32(FixtureFactory):
313+
NAME = "uint32"
314+
SORT = 3
315+
316+
@staticmethod
317+
def get_array(size: int) -> np.ndarray:
318+
array = np.arange(INT_START, INT_START + size, dtype=np.uint32)
319+
array.flags.writeable = False
320+
return array
321+
322+
312323
class FFFloat64(FixtureFactory):
313324
NAME = "float64"
314-
SORT = 3
325+
SORT = 4
315326

316327
@staticmethod
317328
def get_array(size: int) -> np.ndarray:
@@ -322,7 +333,7 @@ def get_array(size: int) -> np.ndarray:
322333

323334
class FFFloat32(FixtureFactory):
324335
NAME = "float32"
325-
SORT = 4
336+
SORT = 5
326337

327338
@staticmethod
328339
def get_array(size: int) -> np.ndarray:
@@ -392,17 +403,18 @@ def get_versions() -> str:
392403
CLS_FF = (
393404
FFInt32,
394405
FFInt64,
406+
FFUInt32,
395407
FFUInt64,
396408
FFFloat64,
397409
FFString,
398-
FFString4x,
410+
# FFString4x,
399411
FFBytes,
400412
# FFObject,
401413
)
402414
FF_ORDER = [f.NAME for f in sorted(CLS_FF, key=lambda ff: ff.SORT)]
403415

404416
# -------------------------------------------------------------------------------
405-
NUMBER = 2
417+
NUMBER = 20
406418

407419
from itertools import product
408420

0 commit comments

Comments
 (0)