memoryview Questions
2
I have the issue that I cannot properly close mmap-s in Python after I created a pointer to them. My use case is that I open files (usually that is UIO-devices to work with hardware, but the issue ...
Teague asked 16/11, 2018 at 14:38
4
Solved
Since I found memory-views handy and fast, I try to avoid creating NumPy arrays in cython and work with the views of the given arrays. However, sometimes it cannot be avoided, not to alter an exist...
Sweetsop asked 8/1, 2014 at 20:19
4
Solved
I am converting a Cython memoryview to a numpy array (to be able to use it in pure Python code):
from libc.stdlib cimport realloc
cimport numpy as np
DTYPE = np.float64
ctypedef np.float64_t DTYP...
Hamrah asked 11/9, 2014 at 13:43
6
Checking the documentation on memoryview:
memoryview objects allow Python code to access the internal data of an
object that supports the buffer protocol without copying.
class memoryview(ob...
Garnetgarnett asked 6/9, 2013 at 10:28
1
In my program code I've got numpy value arrays and numpy index arrays. Both are preallocated and predefined during program initialization.
Each part of the program has one array values on which cal...
Ready asked 7/9, 2017 at 14:48
2
Solved
I coded some program which updates a numpy list in each iteration and does some operations on it. the number of iterations depends on time. for example in 1 second, there might be 1000 to 2500 iter...
Qua asked 7/9, 2017 at 17:37
1
I ran into what I thought was going to be a very simple problem (and I hope it is!), which is to take raw data out of memory, and decode it to a Unicode string.
Doing this is the obvious approach,...
Shoup asked 6/5, 2020 at 14:59
2
Solved
I'm trying to convert a numpy array to a MemoryView object because I have to communicate between two programs. The one can only handle NumPy arrays and the other only MemoryView objects.
Convertin...
Kotz asked 11/1, 2018 at 18:14
3
Solved
I'm writing a Python 2.7 extension module in Cython. How do I create a Python object implementing the new-style buffer interface that wraps a chunk of memory given to me by a C library? The chunk o...
Jaworski asked 26/1, 2015 at 23:2
1
Solved
In Cython code, I can allocate some memory and wrap it in a memory view, e.g. like this:
cdef double* ptr
cdef double[::1] view
ptr = <double*> PyMem_Malloc(N*sizeof('double'))
view = <do...
Laudianism asked 28/3, 2016 at 15:5
1
Solved
Cython appears to use a wrong striding whenever I assign a single value to a slice of a multi-dimensional memory view, except when the slice is along the first dimension. I give a complete example ...
Anana asked 2/5, 2019 at 20:14
4
I have a python memoryview pointing to a bytes object on which I would like to perform some processing in cython.
My problem is:
because the bytes object is not writable, cython does not allow ...
Antiscorbutic asked 20/1, 2017 at 12:55
3
Solved
I have a numpy boolean array:
myarr = np.array([[False, True], [True, False]])
If I try to initialise a Cython MemoryView with it, like this:
cdef bint[:,:] mymem = myarr
I get this error:
V...
Wards asked 1/3, 2018 at 20:28
2
Solved
How can I write a Cython function that takes a byte string object (a normal string, a bytearray, or another object that follows the buffer protocol) as a typed memoryview?
According to the Unicode...
Scorch asked 28/1, 2015 at 22:28
1
Trying to run the most basic test of add.delay(1,2) using celery 4.1.0 with Python 3.6.4 and getting the following error:
[2018-02-27 13:58:50,194: INFO/MainProcess] Received task:
exb.tasks.te...
Odoric asked 27/2, 2018 at 22:22
2
Solved
I'm using a lot of 3D memoryviews in Cython, e.g.
cython.declare(a='double[:, :, ::1]')
a = np.empty((10, 20, 30), dtype='double')
I often want to loop over all elements of a. I can do this usin...
Prisoner asked 19/4, 2018 at 11:18
2
Solved
I use a MPI (mpi4py) script (on a single node), which works with a very large object. In order to let all processes have access to the object, I distribute it through comm.bcast(). This copies the ...
Billet asked 9/9, 2015 at 16:43
3
Solved
I'm having trouble passing in this memoryview of integers into this (rather trivial) function. Python is giving me this error:
ValueError: Buffer dtype mismatch, expected 'int' but got 'long'
Ca...
Slier asked 28/8, 2015 at 3:39
1
Solved
When should I use memoryview in Python2.7? I just can't find any profit of using it over regular bytearray. Also memoryview doesn't support string methods, that is making it absolutely unusable. Am...
Wite asked 16/10, 2016 at 10:21
1
Solved
Pythons memoryview does not support datetime64 or timedelta. Ok. But when I try to create a memoryview of a structured array that includes a datetime64 or timedelta, it appears to work... unless I ...
Treadle asked 24/2, 2015 at 23:27
1
Solved
How can I sort a memoryview in-place in Cython? Is there a built-in function that can do it? Right now I have to use a numpy array instead and use numpy's sort, which is very slow.
Ambrose asked 7/7, 2016 at 19:51
1
Solved
The Cython documentation explains very well what they allow for, how you can declare them, and how to use them.
However, it is still not clear to me what they really are. For example, a simple ass...
Whose asked 25/5, 2016 at 8:48
1
I am trying to pass data from a memoryview to a ctypes array, which works fine in Python 3.4 but not in Python 2.7.
When I run
from ctypes import c_byte
data = memoryview(b'012')
array = c_byte *...
Bucephalus asked 11/3, 2015 at 10:53
2
I need to perform a lot of work using 2D numpy arrays of various sizes and I would like to offload these calculations onto cython. The idea is that my 2D numpy arrays would be passed from python to...
Viscometer asked 18/9, 2014 at 16:12
2
Solved
The python documentation on array clearly states that the array conforms to the buffer interface. It even suggest not using the buffer_info() method. But when I try to get a Py_Buffer from C/C++ co...
Morie asked 2/2, 2011 at 17:43
1 Next >
© 2022 - 2024 — McMap. All rights reserved.