← Back to NumPy Course | Chapter 3: Array Attributes | Lesson 5 of 6

itemsize क्या है

itemsize बताता है एक single element कितने bytes लेता है।

In this page:

  1. itemsize
Syntax
python
arr.itemsize

itemsize

itemsize प्रति element bytes की संख्या है, dtype से determined। int64 और float64 8 bytes इस्तेमाल करते हैं, int32 और float32 4, और int8 1। एक छोटा dtype चुनना directly memory कम करता है।

Note: Bool arrays प्रति element 1 byte इस्तेमाल करते हैं, 1 bit नहीं।

उदाहरण: itemsize

python
import numpy as np

for dt in (np.int8, np.int32, np.int64, np.float32, np.float64):
    print(np.dtype(dt).name, np.zeros(1, dtype=dt).itemsize)

# Output:
# int8 1
# int32 4
# int64 8
# float32 4
# float64 8
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. bytes को bits से confuse करना
  2. यह मान लेना कि सारे ints 4 bytes हैं
  3. memory tight होने पर itemsize ignore करना
चैप्टर सारांश
  • itemsize प्रति element bytes है
  • यह dtype पर depend करता है
  • int64 और float64 8 bytes हैं
  • छोटे dtypes memory बचाते हैं
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.