You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// the global int_cache is shared among all instances
401
401
402
-
staticPyObject*int_cache=NULL;
403
-
404
-
// NOTE: this used to be a Py_ssize_t, which can be 32 bits on some machines and might easily overflow with a few very large indices. Using an explicit 64-bit int seems safer
405
-
staticnpy_int64key_count_global=0;
406
-
407
-
// Fill the int_cache up to size_needed with PyObject ints; `size` is not the key_count_global.
408
-
staticint
409
-
int_cache_fill(Py_ssize_tsize_needed)
410
-
{
411
-
PyObject*item;
412
-
if (!int_cache) {
413
-
int_cache=PyList_New(0);
414
-
if (!int_cache) {
415
-
return-1;
416
-
}
417
-
}
418
-
for (Py_ssize_ti=PyList_GET_SIZE(int_cache); i<size_needed; i++) {
419
-
item=PyLong_FromSsize_t(i);
420
-
if (!item) {
421
-
return-1;
422
-
}
423
-
if (PyList_Append(int_cache, item)) {
424
-
Py_DECREF(item);
425
-
return-1;
426
-
}
427
-
Py_DECREF(item);
428
-
}
429
-
return0;
430
-
}
431
-
432
-
// Given the current key_count_global, remove cache elements only if the key_count is less than the the current size of the int_cache.
// // NOTE: this used to be a Py_ssize_t, which can be 32 bits on some machines and might easily overflow with a few very large indices. Using an explicit 64-bit int seems safer
405
+
// static npy_int64 key_count_global = 0;
406
+
407
+
// // Fill the int_cache up to size_needed with PyObject ints; `size` is not the key_count_global.
408
+
// static int
409
+
// int_cache_fill(Py_ssize_t size_needed)
410
+
// {
411
+
// PyObject *item;
412
+
// if (!int_cache) {
413
+
// int_cache = PyList_New(0);
414
+
// if (!int_cache) {
415
+
// return -1;
416
+
// }
417
+
// }
418
+
// for (Py_ssize_t i = PyList_GET_SIZE(int_cache); i < size_needed; i++) {
419
+
// item = PyLong_FromSsize_t(i);
420
+
// if (!item) {
421
+
// return -1;
422
+
// }
423
+
// if (PyList_Append(int_cache, item)) {
424
+
// Py_DECREF(item);
425
+
// return -1;
426
+
// }
427
+
// Py_DECREF(item);
428
+
// }
429
+
// return 0;
430
+
// }
431
+
432
+
// // Given the current key_count_global, remove cache elements only if the key_count is less than the the current size of the int_cache.
433
+
// void
434
+
// int_cache_remove(Py_ssize_t key_count)
435
+
// {
436
+
// if (!key_count) {
437
+
// Py_CLEAR(int_cache);
438
+
// }
439
+
// else if (key_count < PyList_GET_SIZE(int_cache)) {
0 commit comments