Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
7709d6b7
Commit
7709d6b7
authored
Jun 19, 2016
by
Ivan Smirnov
Browse files
Add memoryview type
parent
8b5fc8b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+13
-0
No files found.
include/pybind11/pytypes.h
View file @
7709d6b7
...
...
@@ -570,6 +570,19 @@ public:
}
};
class
memoryview
:
public
object
{
public:
memoryview
(
const
buffer_info
&
info
)
:
memoryview
(
&
info
.
as_pybuffer
())
{
}
memoryview
(
Py_buffer
*
view
)
:
object
(
PyMemoryView_FromBuffer
(
view
),
false
)
{
if
(
!
m_ptr
)
pybind11_fail
(
"Unable to create memoryview from buffer descriptor"
);
}
PYBIND11_OBJECT_DEFAULT
(
memoryview
,
object
,
PyMemoryView_Check
)
};
inline
size_t
len
(
handle
h
)
{
ssize_t
result
=
PyObject_Length
(
h
.
ptr
());
if
(
result
<
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment