Numpy 的 nbytes
屬性返回數組所有元素消耗的內存(以字節為單位)。
例子
a = np.array([4,5,6], dtype="int32")
a.nbytes
12
這裏,數組中的每個數字都表示為 int32
,這意味著每個項目消耗 4 個字節的內存。由於數組中有 3 個元素,因此消耗的總字節數為 4*3=12
。
相關用法
- Python numpy.less()用法及代碼示例
- Python networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path用法及代碼示例
- Python numpy.polynomial.hermite.hermmul用法及代碼示例
- Python numpy.seterrobj用法及代碼示例
- Python networkx.classes.function.edge_subgraph用法及代碼示例
- Python numpy.tril()用法及代碼示例
- Python numpy.around用法及代碼示例
- Python networkx.algorithms.tree.mst.maximum_spanning_edges用法及代碼示例
- Python numpy.random.standard_normal()用法及代碼示例
- Python networkx.algorithms.bipartite.basic.color用法及代碼示例
- Python numpy.select用法及代碼示例
- Python networkx.algorithms.bipartite.cluster.latapy_clustering用法及代碼示例
- Python networkx.readwrite.json_graph.adjacency_data用法及代碼示例
- Python numpy.fft.irfft2用法及代碼示例
- Python numpy.polynomial.hermite_e.hermemul用法及代碼示例
- Python numpy.fft.irfftn用法及代碼示例
- Python numpy.nonzero()用法及代碼示例
- Python numpy.maximum_sctype()用法及代碼示例
- Python numpy.ma.dstack用法及代碼示例
- Python numpy.ma.make_mask_none()用法及代碼示例
- Python numpy.mod用法及代碼示例
- Python numpy.matrix.flatten用法及代碼示例
- Python numpy.ma.MaskedArray.mean用法及代碼示例
- Python numpy.mean()用法及代碼示例
- Python numpy.random.dirichlet用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | nbytes property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。