buffer

What is the recommended way of allocating memory for a typed memory view?

What is the recommended way of allocating memory for a typed memory view? Question: The Cython documentation on typed memory views list three ways of assigning to a typed memory view: from a raw C pointer, from a np.ndarray and from a cython.view.array. Assume that I don’t have data passed in to my cython function …

Total answers: 2

python: Given a BytesIO buffer, generate img tag in html?

python: Given a BytesIO buffer, generate img tag in html? Question: Is it possible to generate a functional image tag in html from a BytesIO buffer? I’d like to do something along these lines: import matplotlib matplotlib.use(‘Agg’) import pylab import Image import io temp_data = {‘x’:[1,2,3],’y’:[2,4,5]} pylab.plot(temp_data[‘x’], temp_data[‘y’]) img_buffer = io.BytesIO() pylab.savefig(img_buffer, format = ‘png’) …

Total answers: 2

What is faster: multiple `send`s or using buffering?

What is faster: multiple `send`s or using buffering? Question: I’m playing around with sockets in C/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket. My ideas: use a send call for every header. Pros: No memory allocation needed. Cons: many send calls — …

Total answers: 4

Binary buffer in Python

Binary buffer in Python Question: In Python you can use StringIO for a file-like buffer for character data. Memory-mapped file basically does similar thing for binary data, but it requires a file that is used as the basis. Does Python have a file object that is intended for binary data and is memory only, equivalent …

Total answers: 3