What is memoryview in Python 3

0 votes
I am new to Python. Recently I came across the concept of memoryview. I am not able to understand it. Can someone help me understand it in an easy way?
Jul 26, 2019 in Python by Neel
• 3,020 points
1,099 views

1 answer to this question.

0 votes
Before we get into what memory views are, we need to first understand about Python's Buffer Protocol.

What is a Buffer Protocol?

Simply said, buffer protocol provides a way to access the internal data of an object. This internal data is a memory array or a buffer.

Buffer protocol allows one object to expose its internal data (buffers) and the other to access those buffers without intermediate copying.

This protocol is only accessible to us at the C-API level and not using our normal code base.

So, in order to expose the same protocol to normal Python code base, memory views are present.

What is a memory view?

Memory view is a safe way to expose the buffer protocol in Python.

It allows you to access the internal buffers of an object by creating a memory view object.

The memoryview() method returns a memory view object of the given argument.
answered Jul 26, 2019 by Arvind
• 3,050 points

Related Questions In Python

+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
4,885 views
+4 votes
7 answers
+1 vote
7 answers
0 votes
1 answer

What is the use of raw_input function in Python?

raw_input fuction is no longer available in ...READ MORE

answered May 2, 2018 in Python by aayushi
• 750 points
1,266 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,443 views
0 votes
1 answer
0 votes
1 answer

What is the difference between str() and repr() functions in Python?

str() is mostly used to create output ...READ MORE

answered Jul 8, 2019 in Python by Arvind
• 3,050 points
1,621 views
0 votes
1 answer

What is the difference between print and pprint in Python?

As per the documentation,  The pprint module provides a capability ...READ MORE

answered Jul 8, 2019 in Python by Arvind
• 3,050 points
6,886 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP