New submission from Daniel Hrisca <daniel.hri...@gmail.com>:
First I have to apologize if this was discussed before; I've searched the issues and googled the problem but I got nothing obvious. I'm trying to pass a memoryview slice as argument to struct packing functions to avoid creating intermediate bytes objects from struct import Struct s = Struct('<2Q500s').pack_into buffer = bytearray(7000) data = bytes(300) s(buffer, 0, 500, 500, memoryview(data)[4:]) and I get this error: error: argument for 's' must be a bytes object Why is it not possible to use memoryviews in this case? It is also strange for me that we can use a memoyview as the target buffer, so this works fine: s(memoryview(buffer)[10:], 0, 500, 500, data[4:]) ---------- messages: 381413 nosy: danielhrisca priority: normal severity: normal status: open title: passing memoryview slice to struct packing functions _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42408> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com