Skip to Main Content
Hands-On Application Development with PyCharm
book

Hands-On Application Development with PyCharm

by Quan Nguyen
September 2019
Beginner to intermediate content levelBeginner to intermediate
494 pages
13h
English
Packt Publishing
Content preview from Hands-On Application Development with PyCharm

Profiling in PyCharm

For this discussion, we will be considering the example that's included in the Chapter06/Profiling subfolder of this book's repository. This subfolder contains a main.py script, which provides the following code:

def custom_sum(n=1000000):    result = 0    for i in range(n):        result += i    return resultdef built_sum(n=1000000):    result = sum(range(n))    return resultif __name__ == '__main__':    print(custom_sum())    #print(built_sum())

As you can probably guess from the code, we will be comparing and contrasting the two ways of computing the sum of the integers going from one to a specific n (whose default value is 1,000,000). The first way (the custom_sum() function) is to loop through all the elements to be summed and add them to a ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

MASTERING PYCHARM

MASTERING PYCHARM

Nafiul Islam

Publisher Resources

ISBN: 9781789348262Supplemental Content