-
Notifications
You must be signed in to change notification settings - Fork 98
Switch Buffer
s to memoryview
s & remove extra copies/allocations
#656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0c823e2
c690446
9ac8d8e
0ade20c
13f8e50
bd1c401
64eed12
31a7446
9069553
1ab9983
f91c283
d0a7721
7bc8022
4341ce3
4baf1e1
0ea019c
2b871c7
bdc7bc9
0bfafed
c17e314
54fd4b2
eac4ef1
a77e8cf
fb5ffac
9b289c6
7d593b8
7d68d53
b6d91ce
2dd1cdf
b7bb7ef
c83136a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
# cython: language_level=3 | ||
|
||
|
||
cdef class Buffer: | ||
cdef: | ||
char *ptr | ||
Py_buffer buffer | ||
size_t nbytes | ||
size_t itemsize | ||
bint acquired | ||
|
||
cpdef release(self) | ||
cdef extern from *: | ||
""" | ||
#define PyBytes_RESIZE(b, n) _PyBytes_Resize(&b, n) | ||
""" | ||
int PyBytes_RESIZE(object b, Py_ssize_t n) except -1 | ||
Comment on lines
+4
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have added this function (macro) to help with resizing It is a thin wrapper around This allows us to in-place truncate |
||
|
||
|
||
cpdef memoryview ensure_continguous_memoryview(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have an
#ifndef
guard to protect against redefinition errorSo far it seems Cython doesn't encounter this error as it defines this once per module. Still it is a good idea to add the guard
Handling in PR: #732