Lines Matching refs:itemsize
109 ndbuf_new(Py_ssize_t nitems, Py_ssize_t itemsize, Py_ssize_t offset, int flags)
115 len = nitems * itemsize;
116 if (offset % itemsize) {
118 "offset must be a multiple of itemsize");
121 if (offset < 0 || offset+itemsize > len) {
151 base->itemsize = 1;
302 Py_ssize_t itemsize)
345 offset = PyLong_FromSsize_t(i*itemsize);
395 pack_single(char *ptr, PyObject *item, const char *fmt, Py_ssize_t itemsize)
416 mview = PyMemoryView_FromMemory(ptr, itemsize, PyBUF_WRITE);
473 copy_rec(const Py_ssize_t *shape, Py_ssize_t ndim, Py_ssize_t itemsize,
484 dstrides[0] == itemsize && sstrides[0] == itemsize) {
485 memmove(dptr, sptr, shape[0] * itemsize);
490 for (i=0, p=mem; i<shape[0]; p+=itemsize, sptr+=sstrides[0], i++) {
492 memcpy(p, xsptr, itemsize);
494 for (i=0, p=mem; i<shape[0]; p+=itemsize, dptr+=dstrides[0], i++) {
496 memcpy(xdptr, p, itemsize);
506 copy_rec(shape+1, ndim-1, itemsize,
519 dest->itemsize != src->itemsize ||
533 /* Copy src to dest. Both buffers must have the same format, itemsize,
551 dest->strides[dest->ndim-1] != dest->itemsize ||
552 src->strides[src->ndim-1] != src->itemsize) {
553 mem = PyMem_Malloc(dest->shape[dest->ndim-1] * dest->itemsize);
560 copy_rec(dest->shape, dest->ndim, dest->itemsize,
572 unpack_single(char *ptr, const char *fmt, Py_ssize_t itemsize)
578 itemsize = 1;
585 mview = PyMemoryView_FromMemory(ptr, itemsize, PyBUF_READ);
612 const Py_ssize_t *suboffsets, Py_ssize_t ndim, Py_ssize_t itemsize)
622 memcpy(item, ptr, itemsize);
644 ndim-1, itemsize);
686 strides[0] = base->itemsize;
708 item = PyMem_Malloc(base->itemsize);
714 mview = PyMemoryView_FromMemory(item, base->itemsize, PyBUF_WRITE);
720 base->ndim, base->itemsize);
766 | base.itemsize | 1 | OK | OK |
789 Py_ssize_t itemsize;
794 itemsize = PyLong_AsSsize_t(tmp);
797 return itemsize;
823 Py_ssize_t itemsize)
833 ret = pack_from_list(mview, items, format, itemsize);
839 base->itemsize = itemsize;
899 s[0] = base->itemsize;
904 s[base->ndim-1] = base->itemsize;
929 verify_structure(Py_ssize_t len, Py_ssize_t itemsize, Py_ssize_t offset,
938 if (ndim == 0 && (offset < 0 || offset+itemsize > len))
942 if (strides[n] % itemsize) {
944 "strides must be a multiple of itemsize");
959 if (imin + offset < 0 || imax + offset + itemsize > len)
1116 base->len *= base->itemsize;
1150 if (verify_structure(base->len, base->itemsize, ndbuf->offset,
1183 Py_ssize_t itemsize;
1211 /* itemsize */
1212 itemsize = get_itemsize(format);
1213 if (itemsize <= 0) {
1214 if (itemsize == 0) {
1216 "itemsize must not be zero");
1241 ndbuf = ndbuf_new(nitems, itemsize, offset, flags);
1248 if (init_simple(ndbuf, items, format, itemsize) < 0)
1462 view->itemsize is the _previous_ itemsize. If shape is present,
1463 the equality product(shape) * itemsize = len still holds at this
1464 point. The equality calcsize(format) = itemsize does _not_ hold
1508 /* product(shape) * itemsize = len and calcsize(format) = itemsize
1580 ptr += base->itemsize * index;
1606 return unpack_single(ptr, base->format, base->itemsize);
1790 return unpack_single(base->buf, base->format, base->itemsize);
1888 return pack_single(ptr, value, dest->format, dest->itemsize);
1905 return pack_single(ptr, value, dest->format, dest->itemsize);
2047 return PyLong_FromSsize_t(base->itemsize);
2138 { "itemsize", (getter)ndarray_get_itemsize, NULL, NULL, NULL},
2348 ret = unpack_single(ptr, view.format, view.itemsize);
2536 v1.itemsize != v2.itemsize ||
2703 1, /* itemsize */