@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.13\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2024-08-16 14:15 +0000\n "
14+ "POT-Creation-Date : 2024-08-31 10:59 +0000\n "
1515"PO-Revision-Date : 2021-06-28 00:47+0000\n "
1616"Last-Translator : Maciej Olko <maciej.olko@gmail.com>, 2021\n "
1717"Language-Team : Polish (https://app.transifex.com/python-doc/teams/5390/pl/)\n "
@@ -433,12 +433,46 @@ msgid ""
433433"dimensional array as follows:"
434434msgstr ""
435435
436+ msgid ""
437+ "ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * "
438+ "strides[n-1];\n"
439+ "item = *((typeof(item) *)ptr);"
440+ msgstr ""
441+
436442msgid ""
437443"As noted above, :c:member:`~Py_buffer.buf` can point to any location within "
438444"the actual memory block. An exporter can check the validity of a buffer with "
439445"this function:"
440446msgstr ""
441447
448+ msgid ""
449+ "def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n"
450+ " \"\"\" Verify that the parameters represent a valid array within\n"
451+ " the bounds of the allocated memory:\n"
452+ " char *mem: start of the physical memory block\n"
453+ " memlen: length of the physical memory block\n"
454+ " offset: (char *)buf - mem\n"
455+ " \"\"\" \n"
456+ " if offset % itemsize:\n"
457+ " return False\n"
458+ " if offset < 0 or offset+itemsize > memlen:\n"
459+ " return False\n"
460+ " if any(v % itemsize for v in strides):\n"
461+ " return False\n"
462+ "\n"
463+ " if ndim <= 0:\n"
464+ " return ndim == 0 and not shape and not strides\n"
465+ " if 0 in shape:\n"
466+ " return True\n"
467+ "\n"
468+ " imin = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n"
469+ " if strides[j] <= 0)\n"
470+ " imax = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n"
471+ " if strides[j] > 0)\n"
472+ "\n"
473+ " return 0 <= offset+imin and offset+imax+itemsize <= memlen"
474+ msgstr ""
475+
442476msgid "PIL-style: shape, strides and suboffsets"
443477msgstr ""
444478
@@ -458,6 +492,21 @@ msgid ""
458492"strides and suboffsets::"
459493msgstr ""
460494
495+ msgid ""
496+ "void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n"
497+ " Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n"
498+ " char *pointer = (char*)buf;\n"
499+ " int i;\n"
500+ " for (i = 0; i < ndim; i++) {\n"
501+ " pointer += strides[i] * indices[i];\n"
502+ " if (suboffsets[i] >=0 ) {\n"
503+ " pointer = *((char**)pointer) + suboffsets[i];\n"
504+ " }\n"
505+ " }\n"
506+ " return (void*)pointer;\n"
507+ "}"
508+ msgstr ""
509+
461510msgid "Buffer-related functions"
462511msgstr ""
463512
0 commit comments