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
-
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.
// For a FAMI, Return appropriate PyObject for items, keys, and values. When values are needed they are retrieved from the int_cache. For consistency with NumPy array iteration, arrays use PyArray_ToScalar instead of PyArray_GETITEM.
414
+
// For a FAMI, Return appropriate PyObject for items, keys, and values. For consistency with NumPy array iteration, arrays use PyArray_ToScalar instead of PyArray_GETITEM.
PyErr_SetString(PyExc_NotImplementedError, "Not supported for array keys");
1724
1660
return-1;
1725
1661
}
1726
-
key_count_global++;
1727
1662
self->keys_size++;
1728
1663
1729
1664
if (grow_table(self, self->keys_size)) {
@@ -1746,7 +1681,7 @@ fam_length(FAMObject *self)
1746
1681
}
1747
1682
1748
1683
1749
-
// Given a key for a FAM, return the Python integer (via the int_cache) associated with that key. Utility function used in both fam_subscript() and fam_get()
1684
+
// Given a key for a FAM, return the Python integer associated with that key. Utility function used in both fam_subscript() and fam_get()
0 commit comments