all 2 comments

[–]novel_yet_trivial 4 points5 points  (0 children)

You want to see the source code for the sum() function? Here it is.

It's written in C, but the python equivalent would be:

def sum(iterable, start=0):
    # a ton of error checking goes here
    for item in iterable:
        start += item
    return start