Skip to content

Instantly share code, notes, and snippets.

@ericosur
Created December 29, 2020 07:42
Show Gist options
  • Save ericosur/187c40b6cb370f147ac4ffe99002f7ab to your computer and use it in GitHub Desktop.
Save ericosur/187c40b6cb370f147ac4ffe99002f7ab to your computer and use it in GitHub Desktop.
sum using python vanilla or numpy
#!/usr/bin/python3.6
# coding: utf-8
'''
brief description for this script
'''
import time
import numpy as np
def main():
''' main '''
start_time = time.time()
count = 1000000000
normalRange = np.arange(count)
print(normalRange.sum())
print('time taken: {} seconds'.format(time.time() - start_time))
if __name__ == '__main__':
main()
#!/usr/bin/python3.6
# coding: utf-8
'''
brief description for this script
'''
import time
def main():
''' main '''
start_time = time.time()
count = 1000000000
normalRange = range(count)
print(sum(normalRange))
print('time taken: {} seconds'.format(time.time() - start_time))
if __name__ == '__main__':
main()
@ericosur
Copy link
Author

merge these two gist into one script and then benchmark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment