Skip to content

Commit f92009f

Browse files
committed
MAINT: simplify identify hash by dropping support for 3.13.0b2 and older
1 parent dec1f8d commit f92009f

2 files changed

Lines changed: 1 addition & 24 deletions

File tree

‎numpy/_core/src/common/npy_hashtable.c‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,15 @@
3030
#endif
3131

3232
#ifdef Py_GIL_DISABLED
33-
#if PY_VERSION_HEX < 0x30d00b3
34-
// TODO: replace with PyMutex when it is public
35-
#define LOCK_TABLE(tb) \
36-
if (!PyThread_acquire_lock(tb->mutex, NOWAIT_LOCK)) { \
37-
PyThread_acquire_lock(tb->mutex, WAIT_LOCK); \
38-
}
39-
#define UNLOCK_TABLE(tb) PyThread_release_lock(tb->mutex);
40-
#define INITIALIZE_LOCK(tb) \
41-
tb->mutex = PyThread_allocate_lock(); \
42-
if (tb->mutex == NULL) { \
43-
PyErr_NoMemory(); \
44-
PyMem_Free(res); \
45-
return NULL; \
46-
}
47-
#define FREE_LOCK(tb) \
48-
if (tb->mutex != NULL) { \
49-
PyThread_free_lock(tb->mutex); \
50-
}
51-
#else
5233
#define LOCK_TABLE(tb) PyMutex_Lock(&tb->mutex)
5334
#define UNLOCK_TABLE(tb) PyMutex_Unlock(&tb->mutex)
5435
#define INITIALIZE_LOCK(tb) memset(&tb->mutex, 0, sizeof(PyMutex))
55-
#define FREE_LOCK(tb)
56-
#endif
5736
#else
5837
// the GIL serializes access to the table so no need
5938
// for locking if it is enabled
6039
#define LOCK_TABLE(tb)
6140
#define UNLOCK_TABLE(tb)
6241
#define INITIALIZE_LOCK(tb)
63-
#define FREE_LOCK(tb)
6442
#endif
6543

6644
/*
@@ -150,7 +128,6 @@ NPY_NO_EXPORT void
150128
PyArrayIdentityHash_Dealloc(PyArrayIdentityHash *tb)
151129
{
152130
PyMem_Free(tb->buckets);
153-
FREE_LOCK(tb);
154131
PyMem_Free(tb);
155132
}
156133

‎numpy/_core/src/common/npy_hashtable.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ typedef struct {
1515
npy_intp nelem; /* number of elements */
1616
#ifdef Py_GIL_DISABLED
1717
#if PY_VERSION_HEX < 0x30d00b3
18-
PyThread_type_lock *mutex;
18+
#error "GIL-disabled builds require Python 3.13.0b3 or newer"
1919
#else
2020
PyMutex mutex;
2121
#endif

0 commit comments

Comments
 (0)