summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/alloc.c9
-rw-r--r--numpy/core/src/multiarray/arrayobject.c8
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src10
-rw-r--r--numpy/core/src/multiarray/conversion_utils.c12
-rw-r--r--numpy/core/src/multiarray/scalartypes.c.src6
5 files changed, 6 insertions, 39 deletions
diff --git a/numpy/core/src/multiarray/alloc.c b/numpy/core/src/multiarray/alloc.c
index a7f34cbe5..c2b7e9ca7 100644
--- a/numpy/core/src/multiarray/alloc.c
+++ b/numpy/core/src/multiarray/alloc.c
@@ -48,11 +48,6 @@ static cache_bucket datacache[NBUCKETS];
static cache_bucket dimcache[NBUCKETS_DIM];
/* as the cache is managed in global variables verify the GIL is held */
-#if defined(NPY_PY3K)
-#define NPY_CHECK_GIL_HELD() PyGILState_Check()
-#else
-#define NPY_CHECK_GIL_HELD() 1
-#endif
/*
* very simplistic small memory block cache to avoid more expensive libc
@@ -67,7 +62,7 @@ _npy_alloc_cache(npy_uintp nelem, npy_uintp esz, npy_uint msz,
void * p;
assert((esz == 1 && cache == datacache) ||
(esz == sizeof(npy_intp) && cache == dimcache));
- assert(NPY_CHECK_GIL_HELD());
+ assert(PyGILState_Check());
if (nelem < msz) {
if (cache[nelem].available > 0) {
return cache[nelem].ptrs[--(cache[nelem].available)];
@@ -102,7 +97,7 @@ static NPY_INLINE void
_npy_free_cache(void * p, npy_uintp nelem, npy_uint msz,
cache_bucket * cache, void (*dealloc)(void *))
{
- assert(NPY_CHECK_GIL_HELD());
+ assert(PyGILState_Check());
if (p != NULL && nelem < msz) {
if (cache[nelem].available < NCACHE) {
cache[nelem].ptrs[cache[nelem].available++] = p;
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c
index 82eda3464..3f2d8706e 100644
--- a/numpy/core/src/multiarray/arrayobject.c
+++ b/numpy/core/src/multiarray/arrayobject.c
@@ -1004,22 +1004,18 @@ _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op,
{
PyArrayObject *result;
PyArrayMultiIterObject *mit;
- int val, cast = 0;
+ int val;
/* Cast arrays to a common type */
if (PyArray_TYPE(self) != PyArray_DESCR(other)->type_num) {
-#if defined(NPY_PY3K)
/*
* Comparison between Bytes and Unicode is not defined in Py3K;
* we follow.
*/
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
-#else
- cast = 1;
-#endif /* define(NPY_PY3K) */
}
- if (cast || (PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(other))) {
+ if (PyArray_ISNOTSWAPPED(self) != PyArray_ISNOTSWAPPED(other)) {
PyObject *new;
if (PyArray_TYPE(self) == NPY_STRING &&
PyArray_DESCR(other)->type_num == NPY_UNICODE) {
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index 077fb0ec8..4586ef3d3 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -1530,7 +1530,7 @@ OBJECT_to_@TOTYPE@(void *input, void *output, npy_intp n,
* #convert = 1*18, 0*3, 1*2,
* 1*18, 0*3, 1*2,
* 0*23#
- * #convstr = (Int*9, Long*2, Float*4, Complex*3, Tuple*3, Long*2)*3#
+ * #convstr = (Long*9, Long*2, Float*4, Complex*3, Tuple*3, Long*2)*3#
*/
#if @convert@
@@ -1556,7 +1556,7 @@ static void
return;
}
-#if defined(NPY_PY3K) && defined(IS_STRING)
+#if defined(IS_STRING)
/* Work around some Python 3K */
new = PyUnicode_FromEncodedObject(temp, "ascii", "strict");
Py_DECREF(temp);
@@ -1571,13 +1571,7 @@ static void
/* call out to the Python builtin given by convstr */
args = Py_BuildValue("(N)", temp);
-#if defined(NPY_PY3K)
-#define PyInt_Type PyLong_Type
-#endif
new = Py@convstr@_Type.tp_new(&Py@convstr@_Type, args, NULL);
-#if defined(NPY_PY3K)
-#undef PyInt_Type
-#endif
Py_DECREF(args);
temp = new;
if (temp == NULL) {
diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c
index 531d138d6..7ad8f9c03 100644
--- a/numpy/core/src/multiarray/conversion_utils.c
+++ b/numpy/core/src/multiarray/conversion_utils.c
@@ -812,18 +812,6 @@ PyArray_PyIntAsIntp_ErrMsg(PyObject *o, const char * msg)
* Since it is the usual case, first check if o is an integer. This is
* an exact check, since otherwise __index__ is used.
*/
-#if !defined(NPY_PY3K)
- if (PyInt_CheckExact(o)) {
- #if (NPY_SIZEOF_LONG <= NPY_SIZEOF_INTP)
- /* No overflow is possible, so we can just return */
- return PyInt_AS_LONG(o);
- #else
- long_value = PyInt_AS_LONG(o);
- goto overflow_check;
- #endif
- }
- else
-#endif
if (PyLong_CheckExact(o)) {
#if (NPY_SIZEOF_LONG < NPY_SIZEOF_INTP)
long_value = PyLong_AsLongLong(o);
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src
index 4ce214429..8f2231492 100644
--- a/numpy/core/src/multiarray/scalartypes.c.src
+++ b/numpy/core/src/multiarray/scalartypes.c.src
@@ -3156,7 +3156,6 @@ ulong_arrtype_hash(PyObject *obj)
return x;
}
-#if (NPY_SIZEOF_INT != NPY_SIZEOF_LONG) || defined(NPY_PY3K)
static npy_hash_t
int_arrtype_hash(PyObject *obj)
{
@@ -3166,7 +3165,6 @@ int_arrtype_hash(PyObject *obj)
}
return x;
}
-#endif
#if defined(NPY_PY3K)
static npy_hash_t
@@ -4359,20 +4357,16 @@ initialize_numeric_types(void)
/**end repeat**/
-#if (NPY_SIZEOF_INT != NPY_SIZEOF_LONG) || defined(NPY_PY3K)
/* We won't be inheriting from Python Int type. */
PyIntArrType_Type.tp_hash = int_arrtype_hash;
-#endif
#if defined(NPY_PY3K)
/* We won't be inheriting from Python Int type. */
PyLongArrType_Type.tp_hash = long_arrtype_hash;
#endif
-#if (NPY_SIZEOF_LONG != NPY_SIZEOF_LONGLONG) || defined(NPY_PY3K)
/* We won't be inheriting from Python Int type. */
PyLongLongArrType_Type.tp_hash = longlong_arrtype_hash;
-#endif
/**begin repeat
* #name = repr, str#