Use numpy.concatenate with sum:

print (np.concatenate(a).sum())

print (np.sum(np.concatenate(a)))
32

Performance: Depends of number of nested arrays and number of values in arrays, so best test in real data:

a = np.array([np.arange(5), np.arange(2), np.arange(7)] * 1000) 
#print (a)

In [40]: %timeit np.concatenate(a).sum()
830 µs ± 22.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [41]: %timeit (np.sum(np.concatenate(a)))
835 µs ± 33.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

#original solution 
In [42]: %timeit sum([np.sum(array) for array in a])
15.3 ms ± 85.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

Another solutions:

In [43]: %timeit sum(np.sum(array) for array in a)
17.4 ms ± 2.27 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)

In [44]: %timeit (sum(np.concatenate(a)))
2.28 ms ± 143 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
Answer from jezrael on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.sum.html
numpy.sum — NumPy v2.5 Manual
Sum of array elements over a given axis. ... Elements to sum. ... Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
🌐
w3resource
w3resource.com › python-exercises › numpy › basic › numpy-basic-exercise-32.php
NumPy: Compute sum of all elements, sum of each column and sum of each row of a given array - w3resource
August 28, 2025 - # Importing the NumPy library with ... Calculating and printing the sum of all elements in the array 'x' using np.sum() print("Sum of all elements:") print(np.sum(x)) # Calculating and printing the sum of each column in the array ...
🌐
Python Examples
pythonexamples.org › python-numpy-sum-of-elements-in-array
Sum of Elements in NumPy Array - Examples
To get the sum of all elements in a NumPy array, you can use the numpy.sum() function.
🌐
Python Tutorial
pythontutorial.net › home › python numpy › numpy sum()
NumPy sum(): Calculate the Sum of Elements in an Array
August 16, 2022 - The numpy sum() function is an aggregate function that takes an array and returns the sum of all elements.
🌐
Codecademy
codecademy.com › docs › python:numpy › ndarray › .sum()
Python:NumPy | ndarray | .sum() | Codecademy
October 31, 2025 - The .sum() method returns the sum of array elements over a given axis. It can compute the sum of all elements or along specific axes in multi-dimensional arrays. ... Looking for an introduction to the theory behind programming?
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.sum.html
numpy.sum — NumPy v2.3 Manual
Sum of array elements over a given axis. ... Elements to sum. ... Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
🌐
GeeksforGeeks
geeksforgeeks.org › python › numpy-sum-in-python
numpy.sum() in Python - GeeksforGeeks
January 30, 2026 - Explanation: np.sum(arr) adds all elements (5 + 10 + 15) and returns the total. numpy.sum(arr, axis=None, dtype=None, out=None, initial=0, keepdims=False) ... axis: Axis along which the sum is computed.
Find elsewhere
🌐
Centron
centron.de › home › tutorials › numpy.sum() in python - tutorial
numpy.sum() in Python - Tutorial – centron
March 1, 2024 - Python numpy sum() function is used to get the sum of array elements over a given axis. ... The array elements are used to calculate the sum. If the axis is not provided, the sum of all the elements is returned.
🌐
Vultr Docs
docs.vultr.com › python › third party › numpy › sum()
Python Numpy sum() - Calculate Array Sum
January 1, 2025 - Start by importing the numpy module. Create an array of numbers. Apply the sum() function to compute the total sum. ... This snippet calculates the sum of all elements in the data array, which results in 10.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.ndarray.sum.html
numpy.ndarray.sum — NumPy v2.5 Manual
ndarray.sum(axis=None, dtype=None, out=None, *, keepdims=<no value>, initial=<no value>, where=<no value>)#
🌐
TutorialKart
tutorialkart.com › numpy › numpy-sum
NumPy sum() - Sum of Array Elements
February 2, 2025 - import numpy as np # Define a 1D array arr = np.array([1, 2, 3, 4, 5]) # Compute sum of all elements total_sum = np.sum(arr) # Print the result print("Sum of all elements:", total_sum)
🌐
NumPy
numpy.org › doc › 1.18 › reference › generated › numpy.sum.html
numpy.sum — NumPy v1.18 Manual
May 24, 2020 - Sum of array elements over a given axis. ... Elements to sum. ... Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › how to use numpy sum() in python
How to Use NumPy Sum() in Python - Spark By {Examples}
March 27, 2024 - The Numpy sum() function in Python is used to compute the sum/total of array elements along a specified axis or all axes if none is specified. This
🌐
Programiz
programiz.com › python-programming › numpy › methods › sum
NumPy sum() (With Examples)
The sum() function is used to calculate the sum of array elements along a specified axis or across all axes. The sum() function is used to calculate the sum of array elements along a specified axis or across all axes. Example import numpy as np array1 = np.array([1, 2, 3, 4, 5]) # use sum() ...
🌐
DataCamp
datacamp.com › doc › numpy › sum
NumPy sum()
Usage The `sum()` function is used to calculate the total of array elements for numerical analysis or data manipulation. It can sum values along specified axes for multi-dimensional arrays to provide insights into datasets. numpy.sum(a, axis=None, dtype=None, out=None, keepdims=<no value>, ...
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.sum.html
numpy.sum — NumPy v2.1 Manual
Sum of array elements over a given axis. ... Elements to sum. ... Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array.
🌐
DigitalOcean
digitalocean.com › community › tutorials › numpy-sum-in-python
numpy.sum() in Python | DigitalOcean
Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-numpy-how-to-find-sum-and-product-of-numpy-array-elements
Python NumPy: How to Find the Sum and Product of NumPy Array Elements in Python | Tutorial Reference
... The keepdims parameter keeps the reduced axis in the result as a dimension of size 1. This is useful for broadcasting in subsequent operations: ... np.cumsum() returns a running total - each element in the result is the sum of all preceding elements plus itself.