Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Memoryview for List
#6
Good practice is to make sure you understand what memoryview is. Best place to start is Python official documentation (class memoryview(obj))

Quote:Create a memoryview that references obj. obj must support the buffer protocol. Built-in objects that support the buffer protocol include bytes and bytearray.

So we need bytes or bytarray (or have our own class).

Maybe following will give general idea:

>>> m = memoryview(b'[1, 2, 3]')
>>> list(m)
[91, 49, 44, 32, 50, 44, 32, 51, 93]
>>> for el in m:
...     print(chr(el))
...
[
1
,
 
2
,
 
3
]
>>> type(m)
memoryview
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Memoryview for List - by saumyagoel - Mar-06-2019, 03:12 AM
RE: Memoryview for List - by Larz60+ - Mar-06-2019, 04:03 AM
RE: Memoryview for List - by saumyagoel - Mar-06-2019, 04:26 AM
RE: Memoryview for List - by Larz60+ - Mar-06-2019, 05:59 AM
RE: Memoryview for List - by saumyagoel - Mar-06-2019, 09:11 AM
RE: Memoryview for List - by perfringo - Mar-06-2019, 09:13 AM
RE: Memoryview for List - by Larz60+ - Mar-06-2019, 09:14 AM
RE: Memoryview for List - by saumyagoel - Mar-06-2019, 11:05 AM
RE: Memoryview for List - by saumyagoel - Mar-07-2019, 03:36 AM
RE: Memoryview for List - by perfringo - Mar-07-2019, 07:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python 3 memoryview : unsupported format <d evason 0 3,562 Nov-21-2018, 04:27 PM
Last Post: evason

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020