import re
check(re.finditer('',''), size('2P'))
# list
- samples = [[], [1,2,3], ['1', '2', '3']]
- for sample in samples:
- check(list(sample), vsize('Pn') + len(sample)*self.P)
+ check(list([]), vsize('Pn'))
+ check(list([1]), vsize('Pn') + 2*self.P)
+ check(list([1, 2]), vsize('Pn') + 2*self.P)
+ check(list([1, 2, 3]), vsize('Pn') + 4*self.P)
# sortwrapper (list)
# XXX
# cmpwrapper (list)
assert(self->ob_item == NULL);
assert(size > 0);
+ /* Since the Python memory allocator has granularity of 16 bytes on 64-bit
+ * platforms (8 on 32-bit), there is no benefit of allocating space for
+ * the odd number of items, and there is no drawback of rounding the
+ * allocated size up to the nearest even number.
+ */
+ size = (size + 1) & ~(size_t)1;
PyObject **items = PyMem_New(PyObject*, size);
if (items == NULL) {
PyErr_NoMemory();