Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8a6e901

Browse files
Merge pull request #363 from chyun/patch-2
PyBuffer_GetBuffer拼写错误应该是PyObject_GetBuffer && 示例代码中没有引入sample
2 parents d82f16e + de11d09 commit 8a6e901

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎source/c15/p03_write_extension_function_operate_on_arrays.rst‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
::
6161

6262
>>> import array
63+
>>> from sample import *
6364
>>> avg(array.array('d',[1,2,3]))
6465
2.0
6566
>>> import numpy
@@ -95,9 +96,9 @@
9596
通过编写能接受并操作数组的代码,你可以编写很好的兼容这些应用程序的自定义代码,
9697
而不是只能兼容你自己的代码。
9798

98-
代码的关键点在于 ``PyBuffer_GetBuffer()`` 函数。
99+
代码的关键点在于 ``PyObject_GetBuffer()`` 函数。
99100
给定一个任意的Python对象,它会试着去获取底层内存信息,它简单的抛出一个异常并返回-1.
100-
传给 ``PyBuffer_GetBuffer()`` 的特殊标志给出了所需的内存缓冲类型。
101+
传给 ``PyObject_GetBuffer()`` 的特殊标志给出了所需的内存缓冲类型。
101102
例如,``PyBUF_ANY_CONTIGUOUS`` 表示是一个连续的内存区域。
102103

103104
对于数组、字节字符串和其他类似对象而言,一个 ``Py_buffer`` 结构体包含了所有底层内存的信息。

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /