DEV Community

Discussion on: Python's Sum or NumPy's np.sum() ???I found a big difference in time!!

Collapse
 
adityaberi8 profile image
Adityaberi

Also Numpy written in C, and executes very quickly as a result. By comparison, Python is a dynamic language that is interpreted by the Python interpreter, converted to byte code, and executed. So compiled C code is always going to be faster. ... Python loops are slower than C loops

Collapse
 
rhymes profile image
rhymes

Python lists are written in C as well: github.com/python/cpython/blob/mas...

The iterator protocol is in C too: github.com/python/cpython/blob/mas...

The sum function, as most builtins, is written in C as well github.com/python/cpython/blob/c00...

;-)

Thread Thread
 
adityaberi8 profile image
Adityaberi

Also i think an array is a collection of homogeneous data-types which are stored in contagious memory locations, on the other hand, a list in Python is collection of heterogeneous data types stored in non-contagious memory locations.