152 questions
1
vote
0
answers
48
views
How does int() operate from memoryview -- does it create an intermediate bytes copy?
I'm very interested in zero-copy operations (and disappointed that memoryview doesn't have all the member functions that bytes does). My application will be pretty intensive in this regard.
Consider ...
1
vote
0
answers
98
views
Getting buffer_info from py::memoryview
Using Pybind11, is there a way to get the py::buffer_info object from a py::memoryview? Or some other way to get the data pointer, number of dimensions, shape, strides, item size from the python ...
1
vote
2
answers
52
views
Dividing QImage into sub-images in PySide2
I have a large image composed of subimages I have received from another program, I will eventually need to use the subimages as icons on buttons. I understand the math to access the bits + bytes of ...
1
vote
1
answer
173
views
Cython fused dtype memoryview won't complie
I have some code where I (am trying to) do roughly the following:
ctypedef fused Raster_t:
numpy.uint8_t
numpy.uint16_t
cdef class MyClass:
# shape is (rows, cols, channels)
cdef ...
0
votes
1
answer
49
views
Cython: How to pass a numpy memoryview to a nogil cdef function
I would like to send a numpy array (memoryview) to another Cython function.
cdef int function(int[:,:] ref) nogil:
pass
cpdef test():
cdef np.ndarray[int, ndim=2] ref = np.full((10,10),0)
...
0
votes
1
answer
61
views
How can I access a buffer or sequence in an unusual order?
I have a block of memory representing RGB values for a 8 row x 32 column matrix. When writing into this block of memory, it would be convenient to treat it as properly ordered. When reading from the ...
0
votes
0
answers
78
views
Overlay a Byte Array already in memory to a Struct in Python
So I'm creating a tool to read variable length records into memory, and access them as a struct.
Reading this information from disk to a structure seems straight forward. I'm using a helper class ...
0
votes
1
answer
89
views
Creating a cython memoryview manually
I have a contiguous 1-d numpy array that holds data. However, this array is really a buffer, and I have several numpy views to access that data. These views have different shapes, ndims, offsets etc .....
1
vote
0
answers
126
views
Cython: Memoryviewslice vs C array
I define a C function with memoryview input to work with a NumPy array, but a pure C-defined temporary float array can not work with 'base_func'. Error:
Operation not allowed without gil
How can I ...
1
vote
1
answer
366
views
python slice assignment and memoryview of bytearray
Sorry if my English is bad, I speak Korean as mother tongue.
I was writing code that changes bytearray partially.
And what I was trying to is to give name for memoryview of some sections of bytearray, ...
1
vote
1
answer
261
views
Cython returned memoryview is always considered uninitialized
Similar to Cython Memoryview as return value, but I didn't see a solution other than hacking the generated C code.
I'm using Cython 3.0, but it looks like the result is the same with <3.
Here's an ...
0
votes
0
answers
94
views
How to transpose a Cython memoryview slice?
I am trying to calculate the transpose of a Cython typed memoryview slice (eg. a 2D part of a 3D array). I am encountering a transpose error specifically when I try to transpose a 2D slice of a 3D ...
1
vote
2
answers
145
views
Why does the memoryview assignment from array have python interactions?
When compiled with cython -a my-file.pyx, this simple line of cdef is annotated as yellow in the html file.
# my-file.pyx
from cpython.array cimport array
def f(double[:] xyz):
cdef double[:] ...
5
votes
0
answers
183
views
Why is the memory view of a numpy record readonly?
Why is Python telling me that the memory view of a record is readonly?
>>> x = np.zeros(1, dtype='d,d,i')
>>> x
array([(0., 0., 0)], dtype=[('f0', '<f8'), ('f1', '<f8'), ('f2', ...
0
votes
1
answer
10k
views
BufferError: memoryview has 1 exported buffer trying to close a shared memory where I put a dataframe of pyarrow data type values
I'm trying to put dataframes of different types in multiprocessing shared memory. When I'm using dataframes that contain python types I've no problem, but when I use pyarrow types I've problems ...