Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 72a3721

Browse files
realeadJulianWgs
authored andcommittedJul 3, 2021
PERF: Check identity first before comparing the objects (pandas-dev#42160)
1 parent 3f33c74 commit 72a3721

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
 

‎asv_bench/benchmarks/algos/isin.py

+10
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,13 @@ def setup(self, dtype, series_type):
325325

326326
def time_isin(self, dtypes, series_type):
327327
self.series.isin(self.values)
328+
329+
330+
class IsInWithLongTupples:
331+
def setup(self):
332+
t = tuple(range(1000))
333+
self.series = Series([t] * 1000)
334+
self.values = [t]
335+
336+
def time_isin(self):
337+
self.series.isin(self.values)

‎pandas/_libs/src/klib/khash_python.h

+3
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ int PANDAS_INLINE tupleobject_cmp(PyTupleObject* a, PyTupleObject* b){
226226

227227

228228
int PANDAS_INLINE pyobject_cmp(PyObject* a, PyObject* b) {
229+
if (a == b) {
230+
return 1;
231+
}
229232
if (Py_TYPE(a) == Py_TYPE(b)) {
230233
// special handling for some built-in types which could have NaNs
231234
// as we would like to have them equivalent, but the usual

0 commit comments

Comments
 (0)
Please sign in to comment.