From a4513ced90da7279db1e9d1d283f9d065972f8b5 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Fri, 14 Feb 2020 17:52:21 +0200 Subject: [PATCH 1/2] Avoid importing from pandas at _libs files --- pandas/_libs/missing.pyx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pandas/_libs/missing.pyx b/pandas/_libs/missing.pyx index 4d17a6f883c1c..1cdba452c6fd2 100644 --- a/pandas/_libs/missing.pyx +++ b/pandas/_libs/missing.pyx @@ -1,6 +1,7 @@ import cython from cython import Py_ssize_t +import platform import numbers import numpy as np @@ -16,17 +17,12 @@ from pandas._libs.tslibs.nattype cimport ( checknull_with_nat, c_NaT as NaT, is_null_datetimelike) from pandas._libs.ops_dispatch import maybe_dispatch_ufunc_to_dunder_op -from pandas.compat import is_platform_32bit - - cdef: float64_t INF = np.inf float64_t NEGINF = -INF int64_t NPY_NAT = util.get_nat() - bint is_32bit = is_platform_32bit() - cpdef bint checknull(object val): """ @@ -361,7 +357,7 @@ class NAType(C_NAType): def __hash__(self): # GH 30013: Ensure hash is large enough to avoid hash collisions with integers - exponent = 31 if is_32bit else 61 + exponent = 31 if platform.architecture()[0] == "32-bit" else 61 return 2 ** exponent - 1 # Binary arithmetic and comparison ops -> propagate From 5c376540a404e8d3e2ab51bc87855cb4e8b943e4 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Sat, 15 Feb 2020 10:26:16 +0200 Subject: [PATCH 2/2] Moved the computation to the top --- pandas/_libs/missing.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/missing.pyx b/pandas/_libs/missing.pyx index 1cdba452c6fd2..ba8a5dd3dd1d7 100644 --- a/pandas/_libs/missing.pyx +++ b/pandas/_libs/missing.pyx @@ -23,6 +23,8 @@ cdef: int64_t NPY_NAT = util.get_nat() + bint is_32bit = platform.architecture()[0] == "32-bit" + cpdef bint checknull(object val): """ @@ -357,7 +359,7 @@ class NAType(C_NAType): def __hash__(self): # GH 30013: Ensure hash is large enough to avoid hash collisions with integers - exponent = 31 if platform.architecture()[0] == "32-bit" else 61 + exponent = 31 if is_32bit else 61 return 2 ** exponent - 1 # Binary arithmetic and comparison ops -> propagate