Do you even Refactor? 003

import timedef getData():
arr = []
for i in range(1000*1000*50):
arr.append(i)
lo, hi = 0, 0
for x in arr:
if x < lo:
lo = x
if x > hi:
hi = x
print(lo, hi)
return arr
def timed(func):
def run():
Tstart = time.time()
func()
Tend = time.time()
Tdt = round(Tend - Tstart, 2)
print(Tdt, 'seconds')
return run
@timed
def main():
data = getData()
print('len:', len(data), 'sum:', sum(data))
main()

--

--

--

Become a rockstar programmer and try to reach genius status on codr https://nevolin.be/codr/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

WebdriverIO Tests Integration with Jenkins

CS371p Spring 2022: Raju Kakarlapudi

CRM Light in Modern SharePoint. The Build.

Four reasons to use ArcGIS Notebooks for ArcGIS Online.

CSS Fundamentals: Margins, Padding & Borders

Yaaaaayyyyy glorrrryyyyyyy!!!!

AGGREGATOR DESIGN PATTERN IN MICROSERVICES

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ilya Nevolin

Ilya Nevolin

Become a rockstar programmer and try to reach genius status on codr https://nevolin.be/codr/

More from Medium

code dictionary

03 of 100 Days Of Code

#100DaysOfCode — Water Container Problem

5 Pro Tips To Become a Better Programmer