Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
array
communitycreator

What is the array itemsize function in Python?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

An array is a collection of multiple elements of the same datatype.

The itemsize function is simply used to check for the length in bytes of one array item in the internal representation.

Syntax

array.itemsize

Parameters

The itemsize function does not take in any parameters.

Return value

The itemsize function returns the length in bytes of one array item in the internal representation of the given array.

Code

Run the code below and see how the itemsize function works.

# importing the array module
import array as arr
# creating an integer data type array
x = arr.array('i', [1,2,3,4,5,6,7])
# using itemsize function
print(x.itemsize)
Using the itemsize function to get length of one array item in bytes

RELATED TAGS

python
array
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring