CLN: Using sum instead of looping
- [ ] closes #xxxx
- [ ] tests added / passed
- [ ] passes `black pandas`
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

@momisbestfriend just as a general comment Python idioms may not always be applicable for Cython. 

Changes like this definitely need benchmarks to go with them I bench marked it (hopefully I did it well)

The test I use to check both is the following:

```python
import numpy as np

from pandas._libs.lib import memory_usage_of_objects

arr = np.random.rand(1, 100)

%timeit memory_usage_of_objects(arr)
```

---

master:
```
In [4]: %timeit memory_usage_of_objects(arr)                                                                  
268 ns ± 16.9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
```

this PR:
```
In [4]: %timeit memory_usage_of_objects(arr)                                                                  
463 ns ± 9.7 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
``` Yea that's a pretty large slowdown. Still ns which is good and I doubt anyone is calling this function in a tight loop so probably invisible to the end user, but in any case I don't think worth changing.

Thanks in any case!