You can always take a look at the .size attribute. It is defined as an integer, and is zero (0) when there are no elements in the array:

Use with AIimport numpy as np
a = np.array([])

if a.size == 0:
    # Do something when `a` is empty
Answer from JoshAdel on Stack Overflow
🌐
Python Guides
pythonguides.com › python-numpy-empty-array
Create An Empty Array Using NumPy In Python
May 7, 2025 - An empty array raises too, and the message names the fix directly: Use array.size > 0. There is more on this in checking whether a NumPy array is empty.
Discussions

python - numpy.empty giving nonempty array - Stack Overflow
OK thanks, I'm trying to make an empty matrix that I can add dimensions to. Are traditional python arrays more suited to this than numpy? More on stackoverflow.com
🌐 stackoverflow.com
Numpy.Empty - Array Not Exactly Empty
Hi NumPy Development Team! I love NumPy! it helps me a lot indeed! But today, I was experimenting with my code which uses NumPy and there seems to be a bug. This is not so much an issue but a minor bug which I am sure the team can solve.... More on github.com
🌐 github.com
January 4, 2019
python - Initialized empty numpy array is not really empty (contains zeros) - Stack Overflow
In order to store many 3D points coordinates tuples in a numpy.ndarray I initialize an empty numpy array before entering a loop for each of some features. To do so, I currently do this before enter... More on stackoverflow.com
🌐 stackoverflow.com
python - Numpy.empty() creating array with non-empty values - Stack Overflow
The arrays created by numpy.zeros have all of their elements initialized to a "zero value". For arrays with dtype=str, this will be the empty string ''. ... empty, unlike zeros, does not set the array values to zero, and may therefore be marginally faster. More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How do I check if a NumPy array is not empty?
arr.size > 0, or simply if arr.size:.
🌐
pythonguides.com
pythonguides.com › check-if-numpy-array-is-empty
How to Check if a NumPy Array Is Empty (arr.size)
Is there a numpy isempty() function?
No. np.isempty raises AttributeError. Use arr.size == 0 or np.size(arr) == 0.
🌐
pythonguides.com
pythonguides.com › check-if-numpy-array-is-empty
How to Check if a NumPy Array Is Empty (arr.size)
Is an array of NaN values empty?
No. NaN values are elements; use isnan when the requirement is missing-value detection rather than emptiness.
🌐
pythonpool.com
pythonpool.com › home › numpy › check if a numpy array is empty: size, shape, and safe tests
Check if a NumPy Array Is Empty: size, shape, and Safe Tests
🌐
TutorialsPoint
tutorialspoint.com › article › what-is-the-preferred-method-to-check-for-an-empty-array-in-numpy
What is the preferred method to check for an empty array in NumPy?
March 26, 2026 - The most preferred and efficient method is using the size attribute, which returns the total number of elements in the array ? import numpy as np # Creating an empty array empty_array = np.array([]) # Creating a non-empty array data_array = ...
🌐
Python Pool
pythonpool.com › home › numpy › check if a numpy array is empty: size, shape, and safe tests
Check if a NumPy Array Is Empty: size, shape, and Safe Tests
July 13, 2026 - Use array.size == 0 for emptiness; an array can contain elements that are NaN, zero, or False without being empty. The most reliable way to check whether a NumPy array is empty is to test whether it contains zero elements.
🌐
Codemia
codemia.io › home › knowledge hub › how can i check whether a numpy array is empty or not?
How can I check whether a numpy array is empty or not? | Codemia
September 24, 2025 - Use array.size == 0 to check if a NumPy array is empty — this works for all dimensions · Do not use if array: — NumPy raises ValueError for multi-element arrays
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.empty.html
numpy.empty — NumPy v2.5 Manual
Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument. New in version 1.20.0. ... Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty ...
Find elsewhere
🌐
Python Guides
pythonguides.com › check-if-numpy-array-is-empty
How to Check if a NumPy Array Is Empty (arr.size)
May 6, 2025 - To check if a NumPy array is empty, test arr.size == 0. size is the total number of elements, so it is 0 only when the array holds nothing, whatever its shape. Don’t use if not arr: (it raises an error for arrays with more than one element), and be careful with len(arr), which only counts the first dimension.
🌐
GitHub
github.com › numpy › numpy › issues › 12661
Numpy.Empty - Array Not Exactly Empty · Issue #12661 · numpy/numpy · GitHub
January 4, 2019 - I love NumPy! it helps me a lot indeed! But today, I was experimenting with my code which uses NumPy and there seems to be a bug. This is not so much an issue but a minor bug which I am sure the team can solve. If my perception is correct, numpy.empty creates an empty array with a given shape.
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.empty.html
numpy.empty — NumPy v2.6.dev0 Manual
Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument. ... Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty array with shape and type of input.
🌐
IncludeHelp
includehelp.com › python › how-to-check-whether-a-numpy-array-is-empty-or-not.aspx
How to check whether a NumPy array is empty or not?
May 26, 2023 - Consider the below Python program to check NumPy array is empty or not using numpy.any() method.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.empty.html
numpy.empty — NumPy v2.2 Manual
Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument. New in version 1.20.0. ... Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty ...
🌐
Sling Academy
slingacademy.com › article › numpy-test-if-an-array-is-empty-or-not-3-examples
NumPy: Test if an array is empty or not (3 examples) - Sling Academy
The array is empty. Another way to determine if a NumPy array is empty is by examining its shape attribute. An empty array will have a shape that returns a tuple with its dimensions.
🌐
Data Science Parichay
datascienceparichay.com › home › blog › how to check if a numpy array is empty?
How to Check if a Numpy Array is Empty? - Data Science Parichay
November 28, 2022 - To check if a numpy array is empty, use the array's .size attribute and check if it's equal to 0 (an array's size is zero if it has no elements).
🌐
NumPy
numpy.org › doc › 1.25 › reference › generated › numpy.empty.html
numpy.empty — NumPy v1.25 Manual
>>> np.empty([2, 2], dtype=int) array([[-1073741821, -1067949133], [ 496041986, 19249760]]) #uninitialized
🌐
Reddit
reddit.com › r/learnpython › why does numpy.empty put numbers on the order of 1^9 or 1^(-300) in the array?
r/learnpython on Reddit: Why does numpy.empty put numbers on the order of 1^9 or 1^(-300) in the array?
August 4, 2022 -

https://numpy.org/doc/stable/reference/generated/numpy.empty.html

It shows that the returned value of numpy.empty is an array with either very small numbers on the order of 1-300 or very large ones on the order of millions or billions.

Why doesn't it just return an empty array?

And why do they use these value instead of 0s? Don't these very small and large values actually take more space since there are more significant digits to represent? For an empty array we would want the lowest memory footprint which should be an array of all 0s.

How can using these numbers with many digits to be represented be faster than an array of all 0s (as the docs claim)?

Top answer
1 of 5
3
It's allocating the memory without initializing. The memory contains whatever was already there, which could be bits of a program or a string or anything at all. Interpreting those random bit patterns as numbers, it's not surprising they might happen to correspond to very large or very small exponents. So it's not "using" any values. That's just the numeric value that's displayed when the array element happened to be the 47,042-th pixel in the picture of somebody's cat.
2 of 5
3
The other responses are correct that empty creates an array by allocating some memory without overwriting the existing values, and then just interpreting that memory as an array. Something the other responses haven’t covered, Don’t these very small and large values actually take more space … ? No. Numpy arrays are created with a single datatype (the default for empty is float, but you can change it with the dtype parameter), and each value in the array has the same amount of memory allocated to it (which is part of why they’re fast to use and operate on). Computers store numbers as some encoding of bits (binary zeros and ones), and floating point is a special type of encoding that allows representing fractional numbers of varying sizes - effectively one bit is used for the sign (+/-), some of the bits are used to specify order of magnitude (how close or far a number is from zero), and the rest are used to specify the details / significant figures. All the bits are always used for the given datatype, but depending on the numbers you’re trying to represent some of the least significant bits won’t be meaningful to you / for your application. Accordingly, two 64-bit float numbers should have roughly the same number of significant figures, but a very large number will have most or all of its significant figures above the decimal point (when the number is converted to a decimal representation, for a human to read), and a very small number will have most or all of them below the decimal point. It’s a very clever way of being able to handle numbers with significant size variation, but does mean that numbers aren’t specified ‘exactly’ as a human would think about them. If you have an application that requires exact numbers of decimal points (that you choose) you can generally use integers that are some factor of 10 larger than their ‘real’ values. Alternatively there’s the decimal module, but calculations will be less efficient, and it’s not necessary for most applications - especially ones working with large arrays of numbers.
🌐
Python Guides
pythonguides.com › create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
January 12, 2026 - For a list, if not items:. For a NumPy array, use arr.size == 0, because the truth value of an empty NumPy array raises ValueError.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Create an empty array (np.empty, np.empty_like) | note.nkmk.me
January 22, 2024 - This article explains how to create an empty array (ndarray) in NumPy. There are two methods available: np.empty(), which allows specifying any shape and data type (dtype), and np.empty_like(), which ...