No, because the array of 100 elements will only have the overhead once,
while the 100 arrays will each have the overhead repeated.


Think about the overhead like a book cover on a book. It takes additional
space, but provides storage for the book, information to help you find it,
etc. Each book only needs one cover. So a single 100 page book only needs
one cover, while a hundred 1 page books needs 100 covers. Also, as the book
gets more pages the cover takes a smaller portion of the total size of the
book.

On Sat, Mar 13, 2021, 16:17 <klark--k...@yandex.ru> wrote:

> So is it right that 100 arrays of one element is smaller than one array
> with size of 100 elements?
>
> 14.03.2021, 00:06, "Todd" <toddr...@gmail.com>:
>
> Ideally float64 uses 64 bits for each number while float16 uses 16 bits.
> 64/16=4.  However, there is some additional overhead.  This overhead makes
> up a large portion of small arrays, but becomes negligible as the array
> gets bigger.
>
> On Sat, Mar 13, 2021, 16:01 <klark--k...@yandex.ru> wrote:
>
> Dear colleagues!
>
> Size of np.float16(1) is 26
> Size of np.float64(1) is 32
> 32 / 26 = 1.23
>
> Since memory is limited I have a question after this code:
>
>    import numpy as np
>    import sys
>
>    a1 = np.ones(1, dtype='float16')
>    b1 = np.ones(1, dtype='float64')
>    div_1 = sys.getsizeof(b1) / sys.getsizeof(a1)
>    # div_1 = 1.06
>
>    a2 = np.ones(10, dtype='float16')
>    b2 = np.ones(10, dtype='float64')
>    div_2 = sys.getsizeof(b2) / sys.getsizeof(a2)
>    # div_2 = 1.51
>
>    a3 = np.ones(100, dtype='float16')
>    b3 = np.ones(100, dtype='float64')
>    div_3 = sys.getsizeof(b3) / sys.getsizeof(a3)
>    # div_3 = 3.0
> Size of np.float64 numpy arrays is four times more than for np.float16.
> Is it possible to minimize the difference close to 1.23?
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to