Skip to content

Commit 3aec078

Browse files
committed
smaller benches, explanatory comment
1 parent 339ad1a commit 3aec078

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

asv_bench/benchmarks/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def setup(self):
515515
tmp1 = (np.random.random(10000) * 0.1).astype(np.float32)
516516
tmp2 = (np.random.random(10000) * 10.0).astype(np.float32)
517517
tmp = np.concatenate((tmp1, tmp2))
518-
arr = np.repeat(tmp, 100)
518+
arr = np.repeat(tmp, 10)
519519
self.df = DataFrame(dict(a=arr, b=arr))
520520

521521
def time_groupby_sum(self):

asv_bench/benchmarks/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class float_loc(object):
493493
goal_time = 0.2
494494

495495
def setup(self):
496-
a = np.arange(1000000)
496+
a = np.arange(100000)
497497
self.ind = pd.Float64Index(a * 4.8000000418824129e-08)
498498

499499
def time_float_loc(self):

pandas/src/klib/khash_python.h

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
#include "khash.h"
44

5+
// Previously we were using the built in cpython hash function for doubles
6+
// python 2.7 https://github.com/python/cpython/blob/2.7/Objects/object.c#L1021
7+
// python 3.5 https://github.com/python/cpython/blob/3.5/Python/pyhash.c#L85
8+
9+
// The python 3 hash function has the invariant hash(x) == hash(int(x)) == hash(decimal(x))
10+
// and the size of hash may be different by platform / version (long in py2, Py_ssize_t in py3).
11+
// We don't need those invariants because types will be cast before hashing, and if Py_ssize_t
12+
// is 64 bits the truncation causes collission issues. Given all that, we use our own
13+
// simple hash, viewing the double bytes as an int64 and using khash's default
14+
// hash for 64 bit integers.
15+
// GH 13436
516
inline khint64_t asint64(double key) {
617
return *(khint64_t *)(&key);
718
}

0 commit comments

Comments
 (0)