-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathbuffer.po
837 lines (734 loc) · 38.1 KB
/
buffer.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2024, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Fei Yin <icebirds@163.com>, 2018
# 稀饭~~ <wangwhai@qq.com>, 2019
# jacky <jackylvm@foxmail.com>, 2019
# Alpha Du <alphanow@gmail.com>, 2019
# 豌豆花下猫 <chinesehuazhou@gmail.com>, 2019
# Jiu Hong Jiang <julse@qq.com>, 2019
# 8af080f2e6702c64bedd01873aed27e8_25aec74 <fd99d14239138a1f987c22e7736dde81_777475>, 2019
# ppcfish <ppcfish@gmail.com>, 2019
# taotieren <admin@taotieren.com>, 2020
# NCJ <me@ncj.wiki>, 2020
# Jianchao Su, 2020
# jsgang <jsgang9@gmail.com>, 2020
# Jiuh.star <jiuh.star@gmail.com>, 2021
# Dankinder <2535262279@qq.com>, 2021
# helloworldSB <warningfor163@foxmail.com>, 2021
# Dai Xu <daixu61@hotmail.com>, 2021
# Freesand Leo <yuqinju@163.com>, 2021
# Rafael Fontenelle <rffontenelle@gmail.com>, 2024
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.9\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-31 16:34+0000\n"
"PO-Revision-Date: 2017-02-16 17:33+0000\n"
"Last-Translator: Rafael Fontenelle <rffontenelle@gmail.com>, 2024\n"
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../c-api/buffer.rst:11
msgid "Buffer Protocol"
msgstr "缓冲协议"
#: ../../c-api/buffer.rst:18
msgid ""
"Certain objects available in Python wrap access to an underlying memory "
"array or *buffer*. Such objects include the built-in :class:`bytes` and "
":class:`bytearray`, and some extension types like :class:`array.array`. "
"Third-party libraries may define their own types for special purposes, such "
"as image processing or numeric analysis."
msgstr ""
"在 Python 中可使用一些对象来包装对底层内存数组或称 *缓冲* 的访问。此类对象包括内置的 :class:`bytes` 和 "
":class:`bytearray` 以及一些如 :class:`array.array` "
"这样的扩展类型。第三方库也可能会为了特殊的目的而定义它们自己的类型,例如用于图像处理和数值分析等。"
#: ../../c-api/buffer.rst:24
msgid ""
"While each of these types have their own semantics, they share the common "
"characteristic of being backed by a possibly large memory buffer. It is "
"then desirable, in some situations, to access that buffer directly and "
"without intermediate copying."
msgstr "虽然这些类型中的每一种都有自己的语义,但它们具有由可能较大的内存缓冲区支持的共同特征。 在某些情况下,希望直接访问该缓冲区而无需中间复制。"
#: ../../c-api/buffer.rst:29
msgid ""
"Python provides such a facility at the C level in the form of the "
":ref:`buffer protocol <bufferobjects>`. This protocol has two sides:"
msgstr "Python 以 :ref:`缓冲协议 <bufferobjects>` 的形式在 C 层级上提供这样的功能。 此协议包括两个方面:"
#: ../../c-api/buffer.rst:34
msgid ""
"on the producer side, a type can export a \"buffer interface\" which allows "
"objects of that type to expose information about their underlying buffer. "
"This interface is described in the section :ref:`buffer-structs`;"
msgstr ""
"在生产者这一方面,该类型的协议可以导出一个“缓冲区接口”,允许公开它的底层缓冲区信息。该接口的描述信息在 :ref:`buffer-structs` "
"一节中;"
#: ../../c-api/buffer.rst:38
msgid ""
"on the consumer side, several means are available to obtain a pointer to the"
" raw underlying data of an object (for example a method parameter)."
msgstr "在消费者一侧,有几种方法可用于获得指向对象的原始底层数据的指针(例如一个方法的形参)。"
#: ../../c-api/buffer.rst:41
msgid ""
"Simple objects such as :class:`bytes` and :class:`bytearray` expose their "
"underlying buffer in byte-oriented form. Other forms are possible; for "
"example, the elements exposed by an :class:`array.array` can be multi-byte "
"values."
msgstr ""
"一些简单的对象例如 :class:`bytes` 和 :class:`bytearray` 会以面向字节的形式公开它们的底层缓冲区。 "
"也可能会用其他形式;例如 :class:`array.array` 所公开的元素可以是多字节值。"
#: ../../c-api/buffer.rst:45
msgid ""
"An example consumer of the buffer interface is the "
":meth:`~io.BufferedIOBase.write` method of file objects: any object that can"
" export a series of bytes through the buffer interface can be written to a "
"file. While :meth:`write` only needs read-only access to the internal "
"contents of the object passed to it, other methods such as "
":meth:`~io.BufferedIOBase.readinto` need write access to the contents of "
"their argument. The buffer interface allows objects to selectively allow or"
" reject exporting of read-write and read-only buffers."
msgstr ""
"缓冲区接口的消费者的一个例子是文件对象的 :meth:`~io.BufferedIOBase.write` "
"方法:任何可以输出为一系列字节流的对象可以被写入文件。然而 :meth:`write` 方法只需要对于传入对象的只读权限,其他的方法,如 "
":meth:`~io.BufferedIOBase.readinto` "
"需要参数内容的写入权限。缓冲区接口使得对象可以选择性地允许或拒绝读写或只读缓冲区的导出。"
#: ../../c-api/buffer.rst:53
msgid ""
"There are two ways for a consumer of the buffer interface to acquire a "
"buffer over a target object:"
msgstr "对于缓冲区接口的使用者而言,有两种方式来获取一个目的对象的缓冲:"
#: ../../c-api/buffer.rst:56
msgid "call :c:func:`PyObject_GetBuffer` with the right parameters;"
msgstr "使用正确的参数来调用 :c:func:`PyObject_GetBuffer` 函数;"
#: ../../c-api/buffer.rst:58
msgid ""
"call :c:func:`PyArg_ParseTuple` (or one of its siblings) with one of the "
"``y*``, ``w*`` or ``s*`` :ref:`format codes <arg-parsing>`."
msgstr ""
"调用 :c:func:`PyArg_ParseTuple` (或其同级对象之一) 并传入 ``y*``, ``w*`` or ``s*`` "
":ref:`格式代码 <arg-parsing>` 中的一个。"
#: ../../c-api/buffer.rst:61
msgid ""
"In both cases, :c:func:`PyBuffer_Release` must be called when the buffer "
"isn't needed anymore. Failure to do so could lead to various issues such as"
" resource leaks."
msgstr ""
"在这两种情况下,当不再需要缓冲区时必须调用 :c:func:`PyBuffer_Release` 。如果此操作失败,可能会导致各种问题,例如资源泄漏。"
#: ../../c-api/buffer.rst:69
msgid "Buffer structure"
msgstr "缓冲区结构"
#: ../../c-api/buffer.rst:71
msgid ""
"Buffer structures (or simply \"buffers\") are useful as a way to expose the "
"binary data from another object to the Python programmer. They can also be "
"used as a zero-copy slicing mechanism. Using their ability to reference a "
"block of memory, it is possible to expose any data to the Python programmer "
"quite easily. The memory could be a large, constant array in a C extension,"
" it could be a raw block of memory for manipulation before passing to an "
"operating system library, or it could be used to pass around structured data"
" in its native, in-memory format."
msgstr ""
"缓冲区结构(或者简单地称为“buffers”)对于将二进制数据从另一个对象公开给 Python "
"程序员非常有用。它们还可以用作零拷贝切片机制。使用它们引用内存块的能力,可以很容易地将任何数据公开给 Python 程序员。内存可以是 C "
"扩展中的一个大的常量数组,也可以是在传递到操作系统库之前用于操作的原始内存块,或者可以用来传递本机内存格式的结构化数据。"
#: ../../c-api/buffer.rst:80
msgid ""
"Contrary to most data types exposed by the Python interpreter, buffers are "
"not :c:type:`PyObject` pointers but rather simple C structures. This allows"
" them to be created and copied very simply. When a generic wrapper around a"
" buffer is needed, a :ref:`memoryview <memoryview-objects>` object can be "
"created."
msgstr ""
"与 Python 解释器公开的大多部数据类型不同,缓冲区不是 :c:type:`PyObject` 指针而是简单的 C 结构。 "
"这使得它们可以非常简单地创建和复制。 当需要为缓冲区加上泛型包装器时,可以创建一个 :ref:`内存视图 <memoryview-objects>` "
"对象。"
#: ../../c-api/buffer.rst:86
msgid ""
"For short instructions how to write an exporting object, see :ref:`Buffer "
"Object Structures <buffer-structs>`. For obtaining a buffer, see "
":c:func:`PyObject_GetBuffer`."
msgstr ""
"有关如何编写并导出对象的简短说明,请参阅 :ref:`缓冲区对象结构 <buffer-structs>`。 要获取缓冲区对象,请参阅 "
":c:func:`PyObject_GetBuffer`。"
#: ../../c-api/buffer.rst:94
msgid ""
"A pointer to the start of the logical structure described by the buffer "
"fields. This can be any location within the underlying physical memory block"
" of the exporter. For example, with negative :c:member:`~Py_buffer.strides` "
"the value may point to the end of the memory block."
msgstr ""
"指向由缓冲区字段描述的逻辑结构开始的指针。 这可以是导出程序底层物理内存块中的任何位置。 例如,使用负的 "
":c:member:`~Py_buffer.strides` 值可能指向内存块的末尾。"
#: ../../c-api/buffer.rst:99
msgid ""
"For :term:`contiguous` arrays, the value points to the beginning of the "
"memory block."
msgstr "对于 :term:`contiguous` ,‘邻接’数组,值指向内存块的开头。"
#: ../../c-api/buffer.rst:104
msgid ""
"A new reference to the exporting object. The reference is owned by the "
"consumer and automatically decremented and set to ``NULL`` by "
":c:func:`PyBuffer_Release`. The field is the equivalent of the return value "
"of any standard C-API function."
msgstr ""
"对导出对象的新引用。 该引用归使用者所有,并由 :c:func:`PyBuffer_Release` 自动递减并设置为 ``NULL``。 "
"该字段等于任何标准 C-API 函数的返回值。"
#: ../../c-api/buffer.rst:109
msgid ""
"As a special case, for *temporary* buffers that are wrapped by "
":c:func:`PyMemoryView_FromBuffer` or :c:func:`PyBuffer_FillInfo` this field "
"is ``NULL``. In general, exporting objects MUST NOT use this scheme."
msgstr ""
"作为一种特殊情况,对于由 :c:func:`PyMemoryView_FromBuffer` 或 :c:func:`PyBuffer_FillInfo`"
" 包装的 *temporary* 缓冲区,此字段为 ``NULL``。 通常,导出对象不得使用此方案。"
#: ../../c-api/buffer.rst:116
msgid ""
"``product(shape) * itemsize``. For contiguous arrays, this is the length of "
"the underlying memory block. For non-contiguous arrays, it is the length "
"that the logical structure would have if it were copied to a contiguous "
"representation."
msgstr ""
"``product(shape) * "
"itemsize``。对于连续数组,这是基础内存块的长度。对于非连续数组,如果逻辑结构复制到连续表示形式,则该长度将具有该长度。"
#: ../../c-api/buffer.rst:121
msgid ""
"Accessing ``((char *)buf)[0] up to ((char *)buf)[len-1]`` is only valid if "
"the buffer has been obtained by a request that guarantees contiguity. In "
"most cases such a request will be :c:macro:`PyBUF_SIMPLE` or "
":c:macro:`PyBUF_WRITABLE`."
msgstr ""
"仅当缓冲区是通过保证连续性的请求获取时,才访问 ``((char *)buf)[0] up to ((char *)buf)[len-1]`` "
"时才有效。在大多数情况下,此类请求将为 :c:macro:`PyBUF_SIMPLE` 或 :c:macro:`PyBUF_WRITABLE`。"
#: ../../c-api/buffer.rst:127
msgid ""
"An indicator of whether the buffer is read-only. This field is controlled by"
" the :c:macro:`PyBUF_WRITABLE` flag."
msgstr "缓冲区是否为只读的指示器。此字段由 :c:macro:`PyBUF_WRITABLE` 标志控制。"
#: ../../c-api/buffer.rst:132
msgid ""
"Item size in bytes of a single element. Same as the value of "
":func:`struct.calcsize` called on non-``NULL`` :c:member:`~Py_buffer.format`"
" values."
msgstr ""
"单个元素的项大小(以字节为单位)。与 :func:`struct.calcsize` 调用非 ``NULL`` "
":c:member:`~Py_buffer.format` 的值相同。"
#: ../../c-api/buffer.rst:135
msgid ""
"Important exception: If a consumer requests a buffer without the "
":c:macro:`PyBUF_FORMAT` flag, :c:member:`~Py_buffer.format` will be set to "
"``NULL``, but :c:member:`~Py_buffer.itemsize` still has the value for the "
"original format."
msgstr ""
"重要例外:如果使用者请求的缓冲区没有 :c:macro:`PyBUF_FORMAT` 标志,:c:member:`~Py_buffer.format` "
"将设置为 ``NULL``,但 :c:member:`~Py_buffer.itemsize` 仍具有原始格式的值。"
#: ../../c-api/buffer.rst:140
msgid ""
"If :c:member:`~Py_buffer.shape` is present, the equality ``product(shape) * "
"itemsize == len`` still holds and the consumer can use "
":c:member:`~Py_buffer.itemsize` to navigate the buffer."
msgstr ""
"如果 :c:member:`~Py_buffer.shape` 存在,则相等的 ``product(shape) * itemsize == len``"
" 仍然存在,使用者可以使用 :c:member:`~Py_buffer.itemsize` 来导航缓冲区。"
#: ../../c-api/buffer.rst:144
msgid ""
"If :c:member:`~Py_buffer.shape` is ``NULL`` as a result of a "
":c:macro:`PyBUF_SIMPLE` or a :c:macro:`PyBUF_WRITABLE` request, the consumer"
" must disregard :c:member:`~Py_buffer.itemsize` and assume ``itemsize == "
"1``."
msgstr ""
"如果 :c:member:`~Py_buffer.shape` 是 ``NULL``,因为结果为 :c:macro:`PyBUF_SIMPLE` 或 "
":c:macro:`PyBUF_WRITABLE` 请求,则使用者必须忽略 :c:member:`~Py_buffer.itemsize`,并假设 "
"``itemsize == 1``。"
#: ../../c-api/buffer.rst:150
msgid ""
"A *NUL* terminated string in :mod:`struct` module style syntax describing "
"the contents of a single item. If this is ``NULL``, ``\"B\"`` (unsigned "
"bytes) is assumed."
msgstr ""
"在 :mod:`struct` 模块样式语法中 *NUL* 字符串,描述单个项的内容。如果这是 ``NULL``,则假定为 ``\"B\"`` "
"(无符号字节) 。"
#: ../../c-api/buffer.rst:154
msgid "This field is controlled by the :c:macro:`PyBUF_FORMAT` flag."
msgstr "此字段由 :c:macro:`PyBUF_FORMAT` 标志控制。"
#: ../../c-api/buffer.rst:158
msgid ""
"The number of dimensions the memory represents as an n-dimensional array. If"
" it is ``0``, :c:member:`~Py_buffer.buf` points to a single item "
"representing a scalar. In this case, :c:member:`~Py_buffer.shape`, "
":c:member:`~Py_buffer.strides` and :c:member:`~Py_buffer.suboffsets` MUST be"
" ``NULL``."
msgstr ""
"内存表示为 n 维数组的维数。 如果是 ``0``, :c:member:`~Py_buffer.buf` 指向表示标量的单个项目。 "
"在这种情况下,:c:member:`~Py_buffer.shape`、:c:member:`~Py_buffer.strides` 和 "
":c:member:`~Py_buffer.suboffsets` 必须是 ``NULL`` 。"
#: ../../c-api/buffer.rst:163
msgid ""
"The macro :c:macro:`PyBUF_MAX_NDIM` limits the maximum number of dimensions "
"to 64. Exporters MUST respect this limit, consumers of multi-dimensional "
"buffers SHOULD be able to handle up to :c:macro:`PyBUF_MAX_NDIM` dimensions."
msgstr ""
"宏 :c:macro:`PyBUF_MAX_NDIM` 将最大维度数限制为 64。 导出程序必须遵守这个限制,多维缓冲区的使用者应该能够处理最多 "
":c:macro:`PyBUF_MAX_NDIM` 维度。"
#: ../../c-api/buffer.rst:169
msgid ""
"An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` "
"indicating the shape of the memory as an n-dimensional array. Note that "
"``shape[0] * ... * shape[ndim-1] * itemsize`` MUST be equal to "
":c:member:`~Py_buffer.len`."
msgstr ""
"一个长度为 :c:type:`Py_ssize_t` 的数组 :c:member:`~Py_buffer.ndim` 表示作为 n 维数组的内存形状。 "
"请注意,``shape[0] * ... * shape[ndim-1] * itemsize`` 必须等于 "
":c:member:`~Py_buffer.len`。"
#: ../../c-api/buffer.rst:174
msgid ""
"Shape values are restricted to ``shape[n] >= 0``. The case ``shape[n] == 0``"
" requires special attention. See `complex arrays`_ for further information."
msgstr ""
"Shape 形状数组中的值被限定在 ``shape[n] >= 0`` 。 ``shape[n] == 0`` 这一情形需要特别注意。更多信息请参阅 "
"`complex arrays`_ 。"
#: ../../c-api/buffer.rst:178
msgid "The shape array is read-only for the consumer."
msgstr "shape 数组对于使用者来说是只读的。"
#: ../../c-api/buffer.rst:182
msgid ""
"An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim` "
"giving the number of bytes to skip to get to a new element in each "
"dimension."
msgstr ""
"一个长度为 :c:type:`Py_ssize_t` 的数组 :c:member:`~Py_buffer.ndim` "
"给出要跳过的字节数以获取每个尺寸中的新元素。"
#: ../../c-api/buffer.rst:186
msgid ""
"Stride values can be any integer. For regular arrays, strides are usually "
"positive, but a consumer MUST be able to handle the case ``strides[n] <= "
"0``. See `complex arrays`_ for further information."
msgstr ""
"Stride 步幅数组中的值可以为任何整数。对于常规数组,步幅通常为正数,但是使用者必须能够处理 ``strides[n] <= 0`` "
"的情况。更多信息请参阅 `complex arrays`_ 。"
#: ../../c-api/buffer.rst:190
msgid "The strides array is read-only for the consumer."
msgstr "strides数组对用户来说是只读的。"
#: ../../c-api/buffer.rst:194
msgid ""
"An array of :c:type:`Py_ssize_t` of length :c:member:`~Py_buffer.ndim`. If "
"``suboffsets[n] >= 0``, the values stored along the nth dimension are "
"pointers and the suboffset value dictates how many bytes to add to each "
"pointer after de-referencing. A suboffset value that is negative indicates "
"that no de-referencing should occur (striding in a contiguous memory block)."
msgstr ""
"一个长度为 :c:member:`~Py_buffer.ndim` 类型为 :c:type:`Py_ssize_t` 的数组 。如果 "
"``suboffsets[n] >= 0``,则第 n 维存储的是指针,suboffset "
"值决定了解除引用时要给指针增加多少字节的偏移。suboffset 为负值,则表示不应解除引用(在连续内存块中移动)。"
#: ../../c-api/buffer.rst:201
msgid ""
"If all suboffsets are negative (i.e. no de-referencing is needed), then this"
" field must be ``NULL`` (the default value)."
msgstr "如果所有子偏移均为负(即无需取消引用),则此字段必须为 ``NULL`` (默认值)。"
#: ../../c-api/buffer.rst:204
msgid ""
"This type of array representation is used by the Python Imaging Library "
"(PIL). See `complex arrays`_ for further information how to access elements "
"of such an array."
msgstr ""
"Python Imaging Library (PIL) 中使用了这种类型的数组表达方式。请参阅 `complex arrays`_ "
"来了解如何从这样一个数组中访问元素。"
#: ../../c-api/buffer.rst:208
msgid "The suboffsets array is read-only for the consumer."
msgstr "suboffsets 数组对于使用者来说是只读的。"
#: ../../c-api/buffer.rst:212
msgid ""
"This is for use internally by the exporting object. For example, this might "
"be re-cast as an integer by the exporter and used to store flags about "
"whether or not the shape, strides, and suboffsets arrays must be freed when "
"the buffer is released. The consumer MUST NOT alter this value."
msgstr ""
"供输出对象内部使用。比如可能被输出程序重组为一个整数,用于存储一个标志,标明在缓冲区释放时是否必须释放 shape、strides 和 "
"suboffsets 数组。消费者程序 *不得* 修改该值。"
#: ../../c-api/buffer.rst:221
msgid "Buffer request types"
msgstr "缓冲区请求的类型"
#: ../../c-api/buffer.rst:223
msgid ""
"Buffers are usually obtained by sending a buffer request to an exporting "
"object via :c:func:`PyObject_GetBuffer`. Since the complexity of the logical"
" structure of the memory can vary drastically, the consumer uses the *flags*"
" argument to specify the exact buffer type it can handle."
msgstr ""
"通常,通过 :c:func:`PyObject_GetBuffer` "
"向输出对象发送缓冲区请求,即可获得缓冲区。由于内存的逻辑结构复杂,可能会有很大差异,缓冲区使用者可用 *flags* "
"参数指定其能够处理的缓冲区具体类型。"
#: ../../c-api/buffer.rst:228
msgid ""
"All :c:data:`Py_buffer` fields are unambiguously defined by the request "
"type."
msgstr "所有 :c:data:`Py_buffer` 字段均由请求类型明确定义。"
#: ../../c-api/buffer.rst:232
msgid "request-independent fields"
msgstr "与请求无关的字段"
#: ../../c-api/buffer.rst:233
msgid ""
"The following fields are not influenced by *flags* and must always be filled"
" in with the correct values: :c:member:`~Py_buffer.obj`, "
":c:member:`~Py_buffer.buf`, :c:member:`~Py_buffer.len`, "
":c:member:`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`."
msgstr ""
"以下字段不会被 *flags* 影响,并且必须总是用正确的值填充::c:member:`~Py_buffer.obj`, "
":c:member:`~Py_buffer.buf`,:c:member:`~Py_buffer.len`,:c:member:`~Py_buffer.itemsize`,:c:member:`~Py_buffer.ndim`。"
#: ../../c-api/buffer.rst:239
msgid "readonly, format"
msgstr "只读,格式"
#: ../../c-api/buffer.rst:243
msgid ""
"Controls the :c:member:`~Py_buffer.readonly` field. If set, the exporter "
"MUST provide a writable buffer or else report failure. Otherwise, the "
"exporter MAY provide either a read-only or writable buffer, but the choice "
"MUST be consistent for all consumers."
msgstr ""
"控制 :c:member:`~Py_buffer.readonly` 字段。如果设置了,输出程序 *必须* "
"提供一个可写的缓冲区,否则报告失败。若未设置,输出程序 *可以* 提供只读或可写的缓冲区,但对所有消费者程序 *必须* 保持一致。"
#: ../../c-api/buffer.rst:250
msgid ""
"Controls the :c:member:`~Py_buffer.format` field. If set, this field MUST be"
" filled in correctly. Otherwise, this field MUST be ``NULL``."
msgstr ""
"控制 :c:member:`~Py_buffer.format` 字段。 如果设置,则必须正确填写此字段。其他情况下,此字段必须为 ``NULL``。"
#: ../../c-api/buffer.rst:254
msgid ""
":c:macro:`PyBUF_WRITABLE` can be \\|'d to any of the flags in the next "
"section. Since :c:macro:`PyBUF_SIMPLE` is defined as 0, "
":c:macro:`PyBUF_WRITABLE` can be used as a stand-alone flag to request a "
"simple writable buffer."
msgstr ""
":c:macro:`PyBUF_WRITABLE` 可以和下一节的所有标志联用。由于 :c:macro:`PyBUF_SIMPLE` 定义为 0,所以 "
":c:macro:`PyBUF_WRITABLE` 可以作为一个独立的标志,用于请求一个简单的可写缓冲区。"
#: ../../c-api/buffer.rst:258
msgid ""
":c:macro:`PyBUF_FORMAT` can be \\|'d to any of the flags except "
":c:macro:`PyBUF_SIMPLE`. The latter already implies format ``B`` (unsigned "
"bytes)."
msgstr ""
":c:macro:`PyBUF_FORMAT` 可以被设为除了 :c:macro:`PyBUF_SIMPLE` 之外的任何标志。 后者已经按暗示了 "
"``B`` (无符号字节串)格式。"
#: ../../c-api/buffer.rst:263
msgid "shape, strides, suboffsets"
msgstr "形状,步幅,子偏移量"
#: ../../c-api/buffer.rst:265
msgid ""
"The flags that control the logical structure of the memory are listed in "
"decreasing order of complexity. Note that each flag contains all bits of the"
" flags below it."
msgstr "控制内存逻辑结构的标志按照复杂度的递减顺序列出。注意,每个标志包含它下面的所有标志。"
#: ../../c-api/buffer.rst:272 ../../c-api/buffer.rst:296
#: ../../c-api/buffer.rst:321
msgid "Request"
msgstr "请求"
#: ../../c-api/buffer.rst:272 ../../c-api/buffer.rst:296
#: ../../c-api/buffer.rst:321
msgid "shape"
msgstr "形状"
#: ../../c-api/buffer.rst:272 ../../c-api/buffer.rst:296
#: ../../c-api/buffer.rst:321
msgid "strides"
msgstr "步幅"
#: ../../c-api/buffer.rst:272 ../../c-api/buffer.rst:296
#: ../../c-api/buffer.rst:321
msgid "suboffsets"
msgstr "子偏移量"
#: ../../c-api/buffer.rst:274 ../../c-api/buffer.rst:274
#: ../../c-api/buffer.rst:276 ../../c-api/buffer.rst:276
#: ../../c-api/buffer.rst:278 ../../c-api/buffer.rst:298
#: ../../c-api/buffer.rst:298 ../../c-api/buffer.rst:300
#: ../../c-api/buffer.rst:300 ../../c-api/buffer.rst:302
#: ../../c-api/buffer.rst:302 ../../c-api/buffer.rst:304
#: ../../c-api/buffer.rst:323 ../../c-api/buffer.rst:323
#: ../../c-api/buffer.rst:323 ../../c-api/buffer.rst:325
#: ../../c-api/buffer.rst:325 ../../c-api/buffer.rst:325
#: ../../c-api/buffer.rst:327 ../../c-api/buffer.rst:327
#: ../../c-api/buffer.rst:327 ../../c-api/buffer.rst:329
#: ../../c-api/buffer.rst:329 ../../c-api/buffer.rst:329
#: ../../c-api/buffer.rst:331 ../../c-api/buffer.rst:331
#: ../../c-api/buffer.rst:333 ../../c-api/buffer.rst:333
#: ../../c-api/buffer.rst:335 ../../c-api/buffer.rst:337
msgid "yes"
msgstr "是"
#: ../../c-api/buffer.rst:274 ../../c-api/buffer.rst:323
#: ../../c-api/buffer.rst:325
msgid "if needed"
msgstr "如果需要的话"
#: ../../c-api/buffer.rst:276 ../../c-api/buffer.rst:278
#: ../../c-api/buffer.rst:278 ../../c-api/buffer.rst:280
#: ../../c-api/buffer.rst:280 ../../c-api/buffer.rst:280
#: ../../c-api/buffer.rst:298 ../../c-api/buffer.rst:300
#: ../../c-api/buffer.rst:302 ../../c-api/buffer.rst:304
#: ../../c-api/buffer.rst:304 ../../c-api/buffer.rst:327
#: ../../c-api/buffer.rst:329 ../../c-api/buffer.rst:331
#: ../../c-api/buffer.rst:331 ../../c-api/buffer.rst:333
#: ../../c-api/buffer.rst:333 ../../c-api/buffer.rst:335
#: ../../c-api/buffer.rst:335 ../../c-api/buffer.rst:335
#: ../../c-api/buffer.rst:337 ../../c-api/buffer.rst:337
#: ../../c-api/buffer.rst:337
msgid "NULL"
msgstr "NULL"
#: ../../c-api/buffer.rst:287
msgid "contiguity requests"
msgstr "连续性的请求"
#: ../../c-api/buffer.rst:289
msgid ""
"C or Fortran :term:`contiguity <contiguous>` can be explicitly requested, "
"with and without stride information. Without stride information, the buffer "
"must be C-contiguous."
msgstr ""
"可以显式地请求C 或 Fortran :term:`连续 <contiguous>` ,不管有没有步幅信息。若没有步幅信息,则缓冲区必须是 C-连续的。"
#: ../../c-api/buffer.rst:296 ../../c-api/buffer.rst:321
msgid "contig"
msgstr "邻接"
#: ../../c-api/buffer.rst:298 ../../c-api/buffer.rst:304
#: ../../c-api/buffer.rst:335 ../../c-api/buffer.rst:337
msgid "C"
msgstr "C"
#: ../../c-api/buffer.rst:300
msgid "F"
msgstr "F"
#: ../../c-api/buffer.rst:302
msgid "C or F"
msgstr "C 或 F"
#: ../../c-api/buffer.rst:304
msgid ":c:macro:`PyBUF_ND`"
msgstr ":c:macro:`PyBUF_ND`"
#: ../../c-api/buffer.rst:309
msgid "compound requests"
msgstr "复合请求"
#: ../../c-api/buffer.rst:311
msgid ""
"All possible requests are fully defined by some combination of the flags in "
"the previous section. For convenience, the buffer protocol provides "
"frequently used combinations as single flags."
msgstr "所有可能的请求都由上一节中某些标志的组合完全定义。为方便起见,缓冲区协议提供常用的组合作为单个标志。"
#: ../../c-api/buffer.rst:315
msgid ""
"In the following table *U* stands for undefined contiguity. The consumer "
"would have to call :c:func:`PyBuffer_IsContiguous` to determine contiguity."
msgstr "在下表中,*U* 代表连续性未定义。消费者程序必须调用 :c:func:`PyBuffer_IsContiguous` 以确定连续性。"
#: ../../c-api/buffer.rst:321
msgid "readonly"
msgstr "readonly"
#: ../../c-api/buffer.rst:321
msgid "format"
msgstr "format"
#: ../../c-api/buffer.rst:323 ../../c-api/buffer.rst:325
#: ../../c-api/buffer.rst:327 ../../c-api/buffer.rst:329
#: ../../c-api/buffer.rst:331 ../../c-api/buffer.rst:333
msgid "U"
msgstr "U"
#: ../../c-api/buffer.rst:323 ../../c-api/buffer.rst:327
#: ../../c-api/buffer.rst:331 ../../c-api/buffer.rst:335
msgid "0"
msgstr "0"
#: ../../c-api/buffer.rst:325 ../../c-api/buffer.rst:329
#: ../../c-api/buffer.rst:333 ../../c-api/buffer.rst:337
msgid "1 or 0"
msgstr "1 或 0"
#: ../../c-api/buffer.rst:342
msgid "Complex arrays"
msgstr "复杂数组"
#: ../../c-api/buffer.rst:345
msgid "NumPy-style: shape and strides"
msgstr "NumPy-风格:形状和步幅"
#: ../../c-api/buffer.rst:347
msgid ""
"The logical structure of NumPy-style arrays is defined by "
":c:member:`~Py_buffer.itemsize`, :c:member:`~Py_buffer.ndim`, "
":c:member:`~Py_buffer.shape` and :c:member:`~Py_buffer.strides`."
msgstr ""
"NumPy 风格数组的逻辑结构由 :c:member:`~Py_buffer.itemsize` 、 "
":c:member:`~Py_buffer.ndim` 、 :c:member:`~Py_buffer.shape` 和 "
":c:member:`~Py_buffer.strides` 定义。"
#: ../../c-api/buffer.rst:350
msgid ""
"If ``ndim == 0``, the memory location pointed to by "
":c:member:`~Py_buffer.buf` is interpreted as a scalar of size "
":c:member:`~Py_buffer.itemsize`. In that case, both "
":c:member:`~Py_buffer.shape` and :c:member:`~Py_buffer.strides` are "
"``NULL``."
msgstr ""
"如果 ``ndim == 0`` , :c:member:`~Py_buffer.buf` 指向的内存位置被解释为大小为 "
":c:member:`~Py_buffer.itemsize` 的标量。这时, :c:member:`~Py_buffer.shape` 和 "
":c:member:`~Py_buffer.strides` 都为 ``NULL``。"
#: ../../c-api/buffer.rst:354
msgid ""
"If :c:member:`~Py_buffer.strides` is ``NULL``, the array is interpreted as a"
" standard n-dimensional C-array. Otherwise, the consumer must access an "
"n-dimensional array as follows:"
msgstr ""
"如果 :c:member:`~Py_buffer.strides` 为 ``NULL``,则数组将被解释为一个标准的 n 维 C "
"语言数组。否则,消费者程序必须按如下方式访问 n 维数组:"
#: ../../c-api/buffer.rst:364
msgid ""
"As noted above, :c:member:`~Py_buffer.buf` can point to any location within "
"the actual memory block. An exporter can check the validity of a buffer with"
" this function:"
msgstr "如上所述,:c:member:`~Py_buffer.buf` 可以指向实际内存块中的任意位置。输出者程序可以用该函数检查缓冲区的有效性。"
#: ../../c-api/buffer.rst:398
msgid "PIL-style: shape, strides and suboffsets"
msgstr "PIL-风格:形状,步幅和子偏移量"
#: ../../c-api/buffer.rst:400
msgid ""
"In addition to the regular items, PIL-style arrays can contain pointers that"
" must be followed in order to get to the next element in a dimension. For "
"example, the regular three-dimensional C-array ``char v[2][2][3]`` can also "
"be viewed as an array of 2 pointers to 2 two-dimensional arrays: ``char "
"(*v[2])[2][3]``. In suboffsets representation, those two pointers can be "
"embedded at the start of :c:member:`~Py_buffer.buf`, pointing to two ``char "
"x[2][3]`` arrays that can be located anywhere in memory."
msgstr ""
"除了常规项之外, PIL 风格的数组还可以包含指针,必须跟随这些指针才能到达维度的下一个元素。例如,常规的三维 C 语言数组 ``char "
"v[2][2][3]`` 可以看作是一个指向 2 个二维数组的 2 个指针:``char "
"(*v[2])[2][3]``。在子偏移表示中,这两个指针可以嵌入在 :c:member:`~Py_buffer.buf` "
"的开头,指向两个可以位于内存任何位置的 ``char x[2][3]`` 数组。"
#: ../../c-api/buffer.rst:409
msgid ""
"Here is a function that returns a pointer to the element in an N-D array "
"pointed to by an N-dimensional index when there are both non-``NULL`` "
"strides and suboffsets::"
msgstr "这是一个函数,当n维索引所指向的N-D数组中有 ``NULL`` 步长和子偏移量时,它返回一个指针"
#: ../../c-api/buffer.rst:428
msgid "Buffer-related functions"
msgstr "缓冲区相关函数"
#: ../../c-api/buffer.rst:432
msgid ""
"Return ``1`` if *obj* supports the buffer interface otherwise ``0``. When "
"``1`` is returned, it doesn't guarantee that :c:func:`PyObject_GetBuffer` "
"will succeed. This function always succeeds."
msgstr ""
"如果 *obj* 支持缓冲区接口,则返回 ``1``,否则返回 ``0``。 返回 ``1`` 时不保证 "
":c:func:`PyObject_GetBuffer` 一定成功。本函数一定调用成功。"
#: ../../c-api/buffer.rst:439
msgid ""
"Send a request to *exporter* to fill in *view* as specified by *flags*. If "
"the exporter cannot provide a buffer of the exact type, it MUST raise "
":c:data:`PyExc_BufferError`, set ``view->obj`` to ``NULL`` and return "
"``-1``."
msgstr ""
"向 *输出器程序* 发送请求,按照 *flags* 指定的内容填充 *view*。如果 输出器程序不能提供准确类型的缓冲区,*必须* 触发 "
":c:data:`PyExc_BufferError`,设置 ``view->obj`` 为 ``NULL`` 并返回 ``-1``。"
#: ../../c-api/buffer.rst:444
msgid ""
"On success, fill in *view*, set ``view->obj`` to a new reference to "
"*exporter* and return 0. In the case of chained buffer providers that "
"redirect requests to a single object, ``view->obj`` MAY refer to this object"
" instead of *exporter* (See :ref:`Buffer Object Structures <buffer-"
"structs>`)."
msgstr ""
"成功时,填充 *view*,将 ``view->obj`` 设为对 *exporter* 的新引用,并返回 0。 "
"当链式缓冲区提供程序将请求重定向到一个对象时,``view->obj`` 可以引用该对象而不是 *exporter* (参见 "
":ref:`缓冲区对象结构 <buffer-structs>`)。"
#: ../../c-api/buffer.rst:449
msgid ""
"Successful calls to :c:func:`PyObject_GetBuffer` must be paired with calls "
"to :c:func:`PyBuffer_Release`, similar to :c:func:`malloc` and "
":c:func:`free`. Thus, after the consumer is done with the buffer, "
":c:func:`PyBuffer_Release` must be called exactly once."
msgstr ""
":c:func:`PyObject_GetBuffer` 必须与 :c:func:`PyBuffer_Release` 同时调用成功,类似于 "
":c:func:`malloc` 和 :c:func:`free`。因此,消费者程序用完缓冲区后, :c:func:`PyBuffer_Release`"
" 必须保证被调用一次。"
#: ../../c-api/buffer.rst:457
msgid ""
"Release the buffer *view* and decrement the reference count for "
"``view->obj``. This function MUST be called when the buffer is no longer "
"being used, otherwise reference leaks may occur."
msgstr "释放缓冲区 *view* 并递减 ``view->obj`` 的引用计数。该函数必须在缓冲区不再使用时才能调用,否则可能会发生引用泄漏。"
#: ../../c-api/buffer.rst:461
msgid ""
"It is an error to call this function on a buffer that was not obtained via "
":c:func:`PyObject_GetBuffer`."
msgstr "若该函数针对的缓冲区不是通过 :c:func:`PyObject_GetBuffer` 获得的,将会出错。"
#: ../../c-api/buffer.rst:467
msgid ""
"Return the implied :c:data:`~Py_buffer.itemsize` from "
":c:data:`~Py_buffer.format`. On error, raise an exception and return -1."
msgstr ""
"返回 :c:data:`~Py_buffer.itemsize` 中隐含的 :c:data:`~Py_buffer.format` "
"。如果出错,会触发异常并返回 -1。"
#: ../../c-api/buffer.rst:475
msgid ""
"Return ``1`` if the memory defined by the *view* is C-style (*order* is "
"``'C'``) or Fortran-style (*order* is ``'F'``) :term:`contiguous` or either "
"one (*order* is ``'A'``). Return ``0`` otherwise. This function always "
"succeeds."
msgstr ""
"如果 *view* 定义的内存是 C 风格(*order* 为 ``'C'``)或 Fortran 风格(*order* 为 ``'F'``) "
":term:`contiguous` 或其中之一(*order* 是 ``'A'``),则返回 ``1``。否则返回 ``0``。该函数总会成功。"
#: ../../c-api/buffer.rst:482
msgid ""
"Get the memory area pointed to by the *indices* inside the given *view*. "
"*indices* must point to an array of ``view->ndim`` indices."
msgstr ""
"获取给定 *view* 内的 *indices* 所指向的内存区域。*indices* 必须指向一个 ``view->ndim`` 索引的数组。"
#: ../../c-api/buffer.rst:488
msgid ""
"Copy contiguous *len* bytes from *buf* to *view*. *fort* can be ``'C'`` or "
"``'F'`` (for C-style or Fortran-style ordering). ``0`` is returned on "
"success, ``-1`` on error."
msgstr ""
"从 *buf* 复制连续的 *len* 字节到 *view* 。*fort* 可以是 ``'C'`` 或 ``'F'`` (对应于 C 风格或 "
"Fortran 风格的顺序)。成功时返回 ``0`` ,错误时返回 ``-1`` 。"
#: ../../c-api/buffer.rst:495
msgid ""
"Copy *len* bytes from *src* to its contiguous representation in *buf*. "
"*order* can be ``'C'`` or ``'F'`` or ``'A'`` (for C-style or Fortran-style "
"ordering or either one). ``0`` is returned on success, ``-1`` on error."
msgstr ""
"从 *src* 复制 *len* 字节到 *buf* ,成为连续字节串的形式。*order* 可以是 ``'C'`` 或 ``'F'`` 或 "
"``'A'`` (对应于 C 风格、Fortran 风格的顺序或其中任意一种)。成功时返回 ``0`` ,出错时返回 ``-1`` 。"
#: ../../c-api/buffer.rst:499
msgid "This function fails if *len* != *src->len*."
msgstr "如果 *len* != *src->len* 则此函数将报错。"
#: ../../c-api/buffer.rst:504
msgid ""
"Fill the *strides* array with byte-strides of a :term:`contiguous` (C-style "
"if *order* is ``'C'`` or Fortran-style if *order* is ``'F'``) array of the "
"given shape with the given number of bytes per element."
msgstr ""
"用给定形状的 :term:`contiguous` 字节串数组 (如果 *order* 为 ``'C'`` 则为 C 风格,如果 *order* 为 "
"``'F'`` 则为 Fortran 风格) 来填充 *strides* 数组,每个元素具有给定的字节数。"
#: ../../c-api/buffer.rst:511
msgid ""
"Handle buffer requests for an exporter that wants to expose *buf* of size "
"*len* with writability set according to *readonly*. *buf* is interpreted as "
"a sequence of unsigned bytes."
msgstr ""
"处理导出程序的缓冲区请求,该导出程序要公开大小为 *len* 的 *buf* ,并根据 *readonly* 设置可写性。*bug* "
"被解释为一个无符号字节序列。"
#: ../../c-api/buffer.rst:515
msgid ""
"The *flags* argument indicates the request type. This function always fills "
"in *view* as specified by flags, unless *buf* has been designated as read-"
"only and :c:macro:`PyBUF_WRITABLE` is set in *flags*."
msgstr ""
"参数 *flags* 表示请求的类型。该函数总是按照 flag 指定的内容填入 *view*,除非 *buf* 设为只读,并且 *flag* 中设置了 "
":c:macro:`PyBUF_WRITABLE` 标志。"
#: ../../c-api/buffer.rst:519
msgid ""
"On success, set ``view->obj`` to a new reference to *exporter* and return 0."
" Otherwise, raise :c:data:`PyExc_BufferError`, set ``view->obj`` to ``NULL``"
" and return ``-1``;"
msgstr ""
"成功时,将 ``view->obj`` 设为 *exporter* 的新引用,并返回 0。否则,引发 "
":c:data:`PyExc_BufferError` ,将 ``view->obj`` 设为 ``NULL``,并返回 ``-1``。"
#: ../../c-api/buffer.rst:523
msgid ""
"If this function is used as part of a :ref:`getbufferproc <buffer-structs>`,"
" *exporter* MUST be set to the exporting object and *flags* must be passed "
"unmodified. Otherwise, *exporter* MUST be ``NULL``."
msgstr ""
"如果此函数用作 :ref:`getbufferproc <buffer-structs>` 的一部分,则 *exporter* "
"必须设置为导出对象,并且必须在未修改的情况下传递 *flags*。否则,*exporter* 必须是 ``NULL``。"