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

nbytes क्या है

nbytes array के data की total memory है जो यह occupy करता है।

In this page:

  1. nbytes
Syntax
python
arr.nbytes    # size * itemsize

nbytes

nbytes size को itemsize से multiply करने के बराबर है। यह सिर्फ element data count करता है, छोटा array object overhead नहीं। यह estimate करने का एक quick तरीका है कि एक बड़ा array कितना RAM इस्तेमाल करेगा।

Note: दस लाख float64 values लगभग 8 MB लेती हैं।

उदाहरण: nbytes

python
import numpy as np

a = np.zeros(1000, dtype=np.float64)
b = np.zeros(1000, dtype=np.float32)
print(a.nbytes, b.nbytes)
print(a.size * a.itemsize == a.nbytes)

# Output:
# 8000 4000
# True
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. यह उम्मीद करना कि nbytes Python object overhead include करेगा
  2. यह भूल जाना कि dtype total को affect करता है
  3. sys.getsizeof से compare करना जो अलग report करता है
चैप्टर सारांश
  • nbytes = size * itemsize होता है
  • सिर्फ element data count करता है
  • Precision आधी करना memory आधी करता है
  • Capacity planning के लिए useful
🔒

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.