Python Array buffer_info() Method



The Python array buffer_info() method is used to retrieve information such as memory address and, length of the array buffer which hold the content of the current array. This method returns the required information in the form of a tuple.

Syntax

Following is the syntax of Python array buffer_info() method −

array_name.buffer_info()

Parameters

This method does not accepts any parameters.

Return Value

This method returns a tuple, which contains the memory address and length of an array.

Example 1

Following is the basic example of Python array buffer_info method −

import array as arr
# Creating an array
my_array1 = arr.array('i',[400,100,220,400,330,540,540])
x = my_array1.buffer_info()
print("The address and length of my_array1:", x)

Output

Following is the output of above code −

The address and length of  my_array1: (1579568776016, 7)

Example 2

In this example, we have created an array of the double type and retrieved it's address and length using buffer_info() method.

import array as arr
#Creating an array
myArray= arr.array('d',[43.5, 5.60, 23.2, 34.6, 7.7])
info = myArray.buffer_info()
print("Address: ", info[0])
print("Length: ", info[1])

Output

Following is the output of above code −

Address:  140381824811680
Length:  5
python_array_methods.htm
Advertisements
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy