7
7
msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
- "POT-Creation-Date : 2024-05-28 00:03+0000 \n "
10
+ "POT-Creation-Date : 2024-09-01 22:24+0800 \n "
11
11
"PO-Revision-Date : 2018-05-23 14:30+0000\n "
12
12
"
Last-Translator :
Adrian Liaw <[email protected] >\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -303,7 +303,7 @@ msgstr ""
303
303
304
304
#: ../../c-api/buffer.rst:218
305
305
msgid "Constants:"
306
- msgstr ""
306
+ msgstr "常數: "
307
307
308
308
#: ../../c-api/buffer.rst:222
309
309
msgid ""
@@ -533,13 +533,52 @@ msgid ""
533
533
"dimensional array as follows:"
534
534
msgstr ""
535
535
536
+ #: ../../c-api/buffer.rst:368
537
+ msgid ""
538
+ "ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * "
539
+ "strides[n-1];\n"
540
+ "item = *((typeof(item) *)ptr);"
541
+ msgstr ""
542
+ "ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * "
543
+ "strides[n-1];\n"
544
+ "item = *((typeof(item) *)ptr);"
545
+
536
546
#: ../../c-api/buffer.rst:374
537
547
msgid ""
538
548
"As noted above, :c:member:`~Py_buffer.buf` can point to any location within "
539
549
"the actual memory block. An exporter can check the validity of a buffer with "
540
550
"this function:"
541
551
msgstr ""
542
552
553
+ #: ../../c-api/buffer.rst:378
554
+ msgid ""
555
+ "def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n"
556
+ " \"\"\" Verify that the parameters represent a valid array within\n"
557
+ " the bounds of the allocated memory:\n"
558
+ " char *mem: start of the physical memory block\n"
559
+ " memlen: length of the physical memory block\n"
560
+ " offset: (char *)buf - mem\n"
561
+ " \"\"\" \n"
562
+ " if offset % itemsize:\n"
563
+ " return False\n"
564
+ " if offset < 0 or offset+itemsize > memlen:\n"
565
+ " return False\n"
566
+ " if any(v % itemsize for v in strides):\n"
567
+ " return False\n"
568
+ "\n"
569
+ " if ndim <= 0:\n"
570
+ " return ndim == 0 and not shape and not strides\n"
571
+ " if 0 in shape:\n"
572
+ " return True\n"
573
+ "\n"
574
+ " imin = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n"
575
+ " if strides[j] <= 0)\n"
576
+ " imax = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n"
577
+ " if strides[j] > 0)\n"
578
+ "\n"
579
+ " return 0 <= offset+imin and offset+imax+itemsize <= memlen"
580
+ msgstr ""
581
+
543
582
#: ../../c-api/buffer.rst:408
544
583
msgid "PIL-style: shape, strides and suboffsets"
545
584
msgstr ""
@@ -562,6 +601,34 @@ msgid ""
562
601
"strides and suboffsets::"
563
602
msgstr ""
564
603
604
+ #: ../../c-api/buffer.rst:423
605
+ msgid ""
606
+ "void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n"
607
+ " Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n"
608
+ " char *pointer = (char*)buf;\n"
609
+ " int i;\n"
610
+ " for (i = 0; i < ndim; i++) {\n"
611
+ " pointer += strides[i] * indices[i];\n"
612
+ " if (suboffsets[i] >=0 ) {\n"
613
+ " pointer = *((char**)pointer) + suboffsets[i];\n"
614
+ " }\n"
615
+ " }\n"
616
+ " return (void*)pointer;\n"
617
+ "}"
618
+ msgstr ""
619
+ "void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n"
620
+ " Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n"
621
+ " char *pointer = (char*)buf;\n"
622
+ " int i;\n"
623
+ " for (i = 0; i < ndim; i++) {\n"
624
+ " pointer += strides[i] * indices[i];\n"
625
+ " if (suboffsets[i] >=0 ) {\n"
626
+ " pointer = *((char**)pointer) + suboffsets[i];\n"
627
+ " }\n"
628
+ " }\n"
629
+ " return (void*)pointer;\n"
630
+ "}"
631
+
565
632
#: ../../c-api/buffer.rst:438
566
633
msgid "Buffer-related functions"
567
634
msgstr ""
0 commit comments