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